extension.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. // Mutter has no layer-shell: turns the engine's per-output toplevels into desktop windows and reports the pointer
  2. // and per-monitor window states (WE 2.8 rules) a Wayland client can't see.
  3. import Clutter from 'gi://Clutter';
  4. import Cogl from 'gi://Cogl';
  5. import GObject from 'gi://GObject';
  6. import Gio from 'gi://Gio';
  7. import GLib from 'gi://GLib';
  8. import Meta from 'gi://Meta';
  9. import Shell from 'gi://Shell';
  10. import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
  11. import * as Main from 'resource:///org/gnome/shell/ui/main.js';
  12. import {WorkspaceBackground} from 'resource:///org/gnome/shell/ui/workspace.js';
  13. const APP_ID = 'linux-wallpaperengine';
  14. const TITLE_PREFIX = 'linux-wallpaperengine wallpaper ';
  15. const BUS_NAME = 'org.linuxwallpaperengine.Shell';
  16. const OBJECT_PATH = '/org/linuxwallpaperengine/Shell';
  17. const API_VERSION = 1;
  18. const FLAG_FOCUSED = 1;
  19. const FLAG_MAXIMIZED = 2;
  20. const FLAG_FULLSCREEN = 4;
  21. const INTERFACE = `
  22. <node>
  23. <interface name="org.linuxwallpaperengine.Shell">
  24. <property name="Version" type="u" access="read"/>
  25. <property name="Supported" type="b" access="read"/>
  26. <property name="NeedsHelper" type="b" access="read"/>
  27. <method name="SpawnHelper">
  28. <arg type="s" name="socket" direction="in"/>
  29. </method>
  30. <method name="GetState">
  31. <arg type="a(sdd)" name="pointer" direction="out"/>
  32. <arg type="a(ssu)" name="windows" direction="out"/>
  33. </method>
  34. <signal name="PointerMoved">
  35. <arg type="a(sdd)" name="pointer"/>
  36. </signal>
  37. <signal name="DesktopButton">
  38. <arg type="b" name="pressed"/>
  39. </signal>
  40. <signal name="WindowsChanged">
  41. <arg type="a(ssu)" name="windows"/>
  42. </signal>
  43. </interface>
  44. </node>`;
  45. // Same rounded work-area clip the overview gives workspace backgrounds; bounds and radius are monitor fractions.
  46. const CLIP_DECLARATIONS = `
  47. uniform vec4 bounds;
  48. uniform vec2 radius;
  49. `;
  50. const CLIP_CODE = `
  51. vec2 p = cogl_tex_coord_in[0].xy;
  52. float inside = step(bounds.x, p.x) * step(p.x, bounds.z) * step(bounds.y, p.y) * step(p.y, bounds.w);
  53. if (radius.x > 0.0 && radius.y > 0.0) {
  54. vec2 corner = clamp(p, bounds.xy + radius, bounds.zw - radius);
  55. inside *= 1.0 - smoothstep(0.96, 1.0, length((p - corner) / radius));
  56. }
  57. cogl_color_out *= inside;
  58. `;
  59. const OverviewClipEffect = GObject.registerClass(
  60. class OverviewClipEffect extends Shell.GLSLEffect {
  61. _init(params) {
  62. super._init(params);
  63. this._boundsLocation = this.get_uniform_location('bounds');
  64. this._radiusLocation = this.get_uniform_location('radius');
  65. }
  66. vfunc_build_pipeline() {
  67. // Cogl samples first, the clip only scales the result
  68. this.add_glsl_snippet(Cogl.SnippetHook.FRAGMENT, CLIP_DECLARATIONS, CLIP_CODE, false);
  69. }
  70. setClip(bounds, radius) {
  71. this.set_uniform_float(this._boundsLocation, 4, bounds);
  72. this.set_uniform_float(this._radiusLocation, 2, radius);
  73. this.queue_repaint();
  74. }
  75. });
  76. // 49+: set_type on any MetaWindow. 46-48: only via MetaWaylandClient for Shell-spawned clients (the helper).
  77. // 45: no Wayland desktop windows, the wallpaper stays lowest in the normal layer like DING.
  78. const CAN_SET_TYPE = typeof Meta.Window.prototype.set_type === 'function';
  79. const CAN_MAKE_DESKTOP = typeof Meta.WaylandClient?.prototype.make_desktop === 'function';
  80. const CAN_HIDE = typeof Meta.WaylandClient?.prototype.hide_from_window_list === 'function';
  81. const SUPPORTED = CAN_SET_TYPE || CAN_HIDE;
  82. const HELPER = 'linux-wallpaperengine-gnome-helper';
  83. // icon extensions using a bottom-layer normal window (DING on Ubuntu 46, its Gtk4 fork)
  84. const DESKTOP_ICON_APPS = ['com.rastersoft.ding', 'com.desktop.ding'];
  85. function isMaximized(window) {
  86. const flags = window.get_maximize_flags ? window.get_maximize_flags() : window.get_maximized();
  87. return flags === Meta.MaximizeFlags.BOTH;
  88. }
  89. function cursorTracker() {
  90. return global.backend.get_cursor_tracker?.() ?? Meta.CursorTracker.get_for_display(global.display);
  91. }
  92. function appIdOf(window) {
  93. return window.get_sandboxed_app_id() || window.get_gtk_application_id() || window.get_wm_class() || '';
  94. }
  95. export default class WallpaperEngineExtension extends Extension {
  96. enable() {
  97. this._wallpapers = new Map();
  98. this._watched = new Map();
  99. this._windowsJson = '';
  100. this._windows = [];
  101. this._pointerIdle = 0;
  102. this._stateIdle = 0;
  103. this._dbus = Gio.DBusExportedObject.wrapJSObject(INTERFACE, this);
  104. this._dbus.export(Gio.DBus.session, OBJECT_PATH);
  105. this._nameId = Gio.bus_own_name_on_connection(Gio.DBus.session, BUS_NAME, Gio.BusNameOwnerFlags.NONE,
  106. null, null);
  107. this._displaySignals = [
  108. global.display.connect('window-created', (_display, window) => this._watch(window)),
  109. global.display.connect('notify::focus-window', () => this._queueState()),
  110. global.display.connect('restacked', () => {
  111. this._pruneWallpapers();
  112. this._keepBelowDesktopWindows();
  113. this._queueState();
  114. }),
  115. ];
  116. this._workspaceSignal = global.workspace_manager.connect('active-workspace-changed',
  117. () => this._queueState());
  118. this._monitorManager = global.backend.get_monitor_manager();
  119. this._monitorSignal = this._monitorManager.connect('monitors-changed', () => {
  120. for (const window of this._wallpapers.keys())
  121. this._place(window);
  122. this._queueState();
  123. this._queuePointer();
  124. });
  125. this._helperClients = new Set();
  126. this._raisedIds = new Map();
  127. this._shown = new Set();
  128. this._cursorTracker = cursorTracker();
  129. this._cursorSignal = this._cursorTracker.connect('position-invalidated', () => this._queuePointer());
  130. this._leftDown = false;
  131. this._leftForwarded = false;
  132. this._pointerOverDesktop = false;
  133. this._paintSignal = global.stage.connect('after-paint', () => this._pollLeftButton());
  134. this._overviewClones = new Map();
  135. this._overviewSignal = Main.overview.connect('showing', () => this._syncOverview());
  136. this._workareaSignal = global.display.connect('workareas-changed', () => this._syncOverview());
  137. for (const actor of global.get_window_actors())
  138. this._watch(actor.meta_window);
  139. this._queueState();
  140. }
  141. disable() {
  142. for (const id of [this._pointerIdle, this._stateIdle]) {
  143. if (id)
  144. GLib.source_remove(id);
  145. }
  146. this._pointerIdle = this._stateIdle = 0;
  147. Main.overview.disconnect(this._overviewSignal);
  148. global.display.disconnect(this._workareaSignal);
  149. for (const background of [...this._overviewClones.keys()])
  150. this._dropOverviewClone(background);
  151. this._overviewClones = null;
  152. this._cursorTracker.disconnect(this._cursorSignal);
  153. global.stage.disconnect(this._paintSignal);
  154. this._monitorManager.disconnect(this._monitorSignal);
  155. global.workspace_manager.disconnect(this._workspaceSignal);
  156. for (const id of this._displaySignals)
  157. global.display.disconnect(id);
  158. for (const [window, ids] of this._watched) {
  159. for (const id of ids)
  160. window.disconnect(id);
  161. }
  162. this._watched.clear();
  163. // otherwise they would be plain windows covering the monitor
  164. for (const window of this._wallpapers.keys())
  165. window.delete(global.display.get_current_time_roundtrip());
  166. this._wallpapers.clear();
  167. Gio.bus_unown_name(this._nameId);
  168. this._dbus.unexport();
  169. this._dbus = null;
  170. this._cursorTracker = this._monitorManager = null;
  171. for (const [window, id] of this._raisedIds)
  172. window.disconnect(id);
  173. this._helperClients = null;
  174. this._raisedIds = null;
  175. this._shown = null;
  176. }
  177. get Version() {
  178. return API_VERSION;
  179. }
  180. get Supported() {
  181. return SUPPORTED;
  182. }
  183. get NeedsHelper() {
  184. return !CAN_SET_TYPE && CAN_HIDE;
  185. }
  186. // Only ever runs our own helper; callers just pick an engine socket in the runtime folder (Flatpak calls come
  187. // through xdg-dbus-proxy, so the caller's pid is meaningless)
  188. SpawnHelperAsync([socket], invocation) {
  189. try {
  190. if (!this.NeedsHelper)
  191. throw new Error('this GNOME Shell makes desktop windows without the helper');
  192. const runtime = `${GLib.get_user_runtime_dir()}/`;
  193. const socketName = socket.startsWith(runtime) ? socket.slice(runtime.length) : '';
  194. if (!/^(app\/[^/]+\/)?lwe-gnome-\d+\.sock$/.test(socketName))
  195. throw new Error(`refusing a helper for ${socket}`);
  196. const helper = GLib.build_filenamev([this.path, HELPER]);
  197. const launcher = new Gio.SubprocessLauncher({flags: Gio.SubprocessFlags.NONE});
  198. const client = Meta.WaylandClient.new(global.context, launcher);
  199. const process = client.spawnv(global.display, [helper, socket]);
  200. this._helperClients.add(client);
  201. process.wait_async(null, () => this._helperClients?.delete(client));
  202. invocation.return_value(null);
  203. } catch (error) {
  204. invocation.return_error_literal(Gio.DBusError, Gio.DBusError.ACCESS_DENIED, error.message);
  205. }
  206. }
  207. GetState() {
  208. return [this._pointer(), this._windows];
  209. }
  210. // fractions from the top left, stage and surface coords differ without scale-monitor-framebuffer
  211. _pointer() {
  212. const [x, y] = global.get_pointer();
  213. const result = [];
  214. for (const [window, connector] of this._wallpapers) {
  215. const frame = window.get_frame_rect();
  216. if (frame.width > 0 && frame.height > 0)
  217. result.push([connector, (x - frame.x) / frame.width, (y - frame.y) / frame.height]);
  218. }
  219. return result;
  220. }
  221. _watch(window) {
  222. if (this._watched.has(window))
  223. return;
  224. // title and app id may come after the window exists
  225. const check = () => {
  226. if (!this._wallpapers.has(window) && this._isWallpaper(window))
  227. this._adopt(window);
  228. this._queueState();
  229. };
  230. const ids = [
  231. window.connect('notify::wm-class', check),
  232. window.connect('notify::title', check),
  233. window.connect('notify::minimized', () => this._queueState()),
  234. window.connect('notify::maximized-horizontally', () => this._queueState()),
  235. window.connect('notify::maximized-vertically', () => this._queueState()),
  236. window.connect('notify::fullscreen', () => this._queueState()),
  237. window.connect('size-changed', () => {
  238. this._queueState();
  239. if (this._wallpapers.has(window))
  240. this._queuePointer();
  241. }),
  242. window.connect('workspace-changed', () => this._queueState()),
  243. window.connect('unmanaged', () => {
  244. for (const id of this._watched.get(window) ?? [])
  245. window.disconnect(id);
  246. this._watched.delete(window);
  247. this._raisedIds?.delete(window);
  248. this._shown?.delete(window);
  249. if (this._wallpapers.delete(window))
  250. this._syncOverview();
  251. this._queueState();
  252. }),
  253. ];
  254. this._watched.set(window, ids);
  255. check();
  256. }
  257. _isWallpaper(window) {
  258. return window.get_client_type() === Meta.WindowClientType.WAYLAND &&
  259. window.get_wm_class() === APP_ID &&
  260. (window.get_title() ?? '').startsWith(TITLE_PREFIX);
  261. }
  262. _adopt(window) {
  263. const connector = window.get_title().slice(TITLE_PREFIX.length);
  264. this._wallpapers.set(window, connector);
  265. // not fullscreen on the engine side (would hide the top bar), the monitor size comes from here
  266. if (CAN_SET_TYPE) {
  267. window.set_type(Meta.WindowType.DESKTOP);
  268. window.hide_from_window_list();
  269. } else {
  270. const client = [...this._helperClients].find(candidate => candidate.owns_window(window));
  271. if (!client) {
  272. console.error(`${this.uuid}: ${window.get_title()} is not from a helper connection, it stays a window`);
  273. return;
  274. }
  275. if (CAN_MAKE_DESKTOP) {
  276. client.make_desktop(window);
  277. } else {
  278. this._raisedIds.set(window, window.connect_after('raised', () => window.lower()));
  279. this._returnFocus(window, global.display.focus_window);
  280. }
  281. client.hide_from_window_list(window);
  282. }
  283. window.stick();
  284. // again when shown, Mutter places new windows on the current monitor
  285. this._place(window);
  286. const shownId = window.connect('shown', () => {
  287. window.disconnect(shownId);
  288. this._shown.add(window);
  289. this._place(window);
  290. this._keepBelowDesktopWindows();
  291. });
  292. this._queuePointer();
  293. this._syncOverview();
  294. }
  295. // The overview hides the window group, so a clone over each workspace background keeps it live
  296. _syncOverview() {
  297. if (!this._overviewClones)
  298. return;
  299. const found = new Set();
  300. const walk = actor => {
  301. if (actor instanceof WorkspaceBackground) {
  302. found.add(actor);
  303. this._syncWorkspaceBackground(actor);
  304. return;
  305. }
  306. for (const child of actor.get_children())
  307. walk(child);
  308. };
  309. walk(Main.layoutManager.overviewGroup);
  310. for (const background of [...this._overviewClones.keys()]) {
  311. if (!found.has(background))
  312. this._dropOverviewClone(background);
  313. }
  314. }
  315. _wallpaperActorOn(monitorIndex) {
  316. for (const window of this._wallpapers.keys()) {
  317. if (window.get_monitor() === monitorIndex && window.get_compositor_private())
  318. return window.get_compositor_private();
  319. }
  320. return null;
  321. }
  322. _syncWorkspaceBackground(background) {
  323. const source = SUPPORTED ? this._wallpaperActorOn(background._monitorIndex) : null;
  324. const existing = this._overviewClones.get(background);
  325. if (existing?.clone.source === source && source) {
  326. this._updateOverviewClip(background, existing);
  327. return;
  328. }
  329. if (existing)
  330. this._dropOverviewClone(background);
  331. if (!source)
  332. return;
  333. const clone = new Clutter.Clone({source, x_expand: true, y_expand: true});
  334. const effect = new OverviewClipEffect();
  335. clone.add_effect(effect);
  336. const group = background._backgroundGroup;
  337. group.add_child(clone);
  338. group.set_child_above_sibling(clone, null);
  339. const entry = {clone, effect, group, signals: [], content: null, contentSignal: 0};
  340. const manager = background._bgManager;
  341. // new background actors go on top
  342. entry.signals.push([manager, manager.connect('changed', () => {
  343. group.set_child_above_sibling(clone, null);
  344. this._updateOverviewClip(background, entry);
  345. })]);
  346. entry.signals.push([background, background.connect('destroy', () => this._dropOverviewClone(background, true))]);
  347. this._overviewClones.set(background, entry);
  348. this._updateOverviewClip(background, entry);
  349. }
  350. _updateOverviewClip(background, entry) {
  351. const content = background._bgManager?.backgroundActor?.content;
  352. if (!content)
  353. return;
  354. if (entry.content !== content) {
  355. if (entry.contentSignal)
  356. entry.content.disconnect(entry.contentSignal);
  357. entry.content = content;
  358. entry.contentSignal = content.connect('notify::rounded-clip-radius',
  359. () => this._updateOverviewClip(background, entry));
  360. }
  361. const monitor = Main.layoutManager.monitors[background._monitorIndex];
  362. const area = background._workarea;
  363. if (!monitor || !area || monitor.width <= 0 || monitor.height <= 0)
  364. return;
  365. const left = (area.x - monitor.x) / monitor.width;
  366. const top = (area.y - monitor.y) / monitor.height;
  367. const radius = content.rounded_clip_radius;
  368. entry.effect.setClip(
  369. [left, top, left + area.width / monitor.width, top + area.height / monitor.height],
  370. [radius / monitor.width, radius / monitor.height]);
  371. }
  372. // the workspace went away with clone and background
  373. _dropOverviewClone(background, destroyed = false) {
  374. const entry = this._overviewClones?.get(background);
  375. if (!entry)
  376. return;
  377. this._overviewClones.delete(background);
  378. if (destroyed)
  379. return;
  380. for (const [object, id] of entry.signals)
  381. object.disconnect(id);
  382. if (entry.contentSignal)
  383. entry.content.disconnect(entry.contentSignal);
  384. entry.clone.destroy();
  385. }
  386. // DING shares the wallpaper's layer and later windows land on top; keep the wallpaper lowest, under the icons
  387. _keepBelowDesktopWindows() {
  388. const stack = global.display.sort_windows_by_stacking(global.display.list_all_windows());
  389. for (const wallpaper of this._wallpapers.keys()) {
  390. const layer = wallpaper.get_layer();
  391. const index = stack.indexOf(wallpaper);
  392. // lowering re-emits restacked
  393. if (stack.slice(0, Math.max(index, 0))
  394. .some(window => window.get_layer() === layer && !this._wallpapers.has(window)))
  395. wallpaper.lower();
  396. }
  397. }
  398. // GNOME 45 drops a gone client's window without 'unmanaged' (Shell 45.2)
  399. _pruneWallpapers() {
  400. const live = new Set(global.display.list_all_windows());
  401. for (const window of [...this._wallpapers.keys()]) {
  402. if (!this._shown.has(window) || live.has(window))
  403. continue;
  404. for (const id of this._watched.get(window) ?? [])
  405. window.disconnect(id);
  406. this._watched.delete(window);
  407. this._wallpapers.delete(window);
  408. this._shown.delete(window);
  409. this._raisedIds.delete(window);
  410. this._syncOverview();
  411. }
  412. }
  413. _returnFocus(window, previous) {
  414. const shownId = window.connect('shown', () => {
  415. window.disconnect(shownId);
  416. if (window.has_focus() && previous && previous !== window && !previous.minimized)
  417. previous.activate(global.display.get_current_time_roundtrip());
  418. });
  419. }
  420. _place(window) {
  421. const connector = this._wallpapers.get(window);
  422. const monitor = this._monitorManager.get_monitor_for_connector(connector);
  423. if (monitor < 0)
  424. return;
  425. const area = global.display.get_monitor_geometry(monitor);
  426. window.move_resize_frame(false, area.x, area.y, area.width, area.height);
  427. }
  428. // Clicks on desktop icons never reach our surface, but WE polls the left button each frame (sub_14010D9B0) and
  429. // counts a press over the icon view. Stage events miss Wayland client input, so poll once per painted frame too.
  430. _pollLeftButton() {
  431. if (this._wallpapers.size === 0)
  432. return;
  433. const [, , mods] = global.get_pointer();
  434. const down = (mods & Clutter.ModifierType.BUTTON1_MASK) !== 0;
  435. if (down === this._leftDown) {
  436. if (!down)
  437. this._updatePointerOverDesktop();
  438. return;
  439. }
  440. this._leftDown = down;
  441. // pick before the press, icons react to it (DING starts a rubber band)
  442. if (down && !Main.overview.visible && this._pointerOverDesktop) {
  443. this._leftForwarded = true;
  444. this._dbus?.emit_signal('DesktopButton', new GLib.Variant('(b)', [true]));
  445. } else if (!down && this._leftForwarded) {
  446. this._leftForwarded = false;
  447. this._dbus?.emit_signal('DesktopButton', new GLib.Variant('(b)', [false]));
  448. }
  449. }
  450. _updatePointerOverDesktop() {
  451. const [x, y] = global.get_pointer();
  452. this._pointerOverDesktop = this._overOtherDesktopWindow(x, y);
  453. }
  454. _overOtherDesktopWindow(x, y) {
  455. let actor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
  456. while (actor && !(actor instanceof Meta.WindowActor))
  457. actor = actor.get_parent();
  458. const window = actor?.get_meta_window();
  459. return !!window && this._isDesktop(window);
  460. }
  461. // other desktop windows and icon windows
  462. _isDesktop(window) {
  463. if (this._wallpapers.has(window))
  464. return false;
  465. return window.get_window_type() === Meta.WindowType.DESKTOP ||
  466. DESKTOP_ICON_APPS.includes(window.get_gtk_application_id());
  467. }
  468. _queuePointer() {
  469. if (this._pointerIdle || this._wallpapers.size === 0)
  470. return;
  471. // one signal per main loop pass
  472. this._pointerIdle = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
  473. this._pointerIdle = 0;
  474. this._dbus?.emit_signal('PointerMoved', new GLib.Variant('(a(sdd))', [this._pointer()]));
  475. return GLib.SOURCE_REMOVE;
  476. });
  477. }
  478. _queueState() {
  479. if (this._stateIdle)
  480. return;
  481. this._stateIdle = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
  482. this._stateIdle = 0;
  483. this._updateState();
  484. return GLib.SOURCE_REMOVE;
  485. });
  486. }
  487. // GNOME 46 can't list logical monitors, only outputs with a wallpaper are reported
  488. _connectorsOf(monitorIndex) {
  489. return [...new Set(this._wallpapers.values())]
  490. .filter(connector => this._monitorManager.get_monitor_for_connector(connector) === monitorIndex);
  491. }
  492. // WE 2.8 (sub_14003D050 / sub_14003BBA0): visible, unminimized windows on the current desktop. Maximized marks its
  493. // monitor; the foreground root window marks focused, and fullscreen if not maximized and at least monitor-sized.
  494. _collectWindows() {
  495. const workspace = global.workspace_manager.get_active_workspace();
  496. const focus = global.display.focus_window?.find_root_ancestor() ?? null;
  497. const windows = [];
  498. for (const actor of global.get_window_actors()) {
  499. const window = actor.meta_window;
  500. if (this._wallpapers.has(window) || window.minimized || !window.showing_on_its_workspace() ||
  501. !window.located_on_workspace(workspace) || window.is_override_redirect())
  502. continue;
  503. if (window.get_window_type() === Meta.WindowType.DOCK || this._isDesktop(window))
  504. continue;
  505. const maximized = isMaximized(window);
  506. let flags = maximized ? FLAG_MAXIMIZED : 0;
  507. if (window === focus) {
  508. flags |= FLAG_FOCUSED;
  509. const frame = window.get_frame_rect();
  510. const area = global.display.get_monitor_geometry(window.get_monitor());
  511. if (!maximized && (window.is_fullscreen() || (frame.width >= area.width && frame.height >= area.height)))
  512. flags |= FLAG_FULLSCREEN;
  513. }
  514. if (flags === 0)
  515. continue;
  516. for (const connector of this._connectorsOf(window.get_monitor()))
  517. windows.push([appIdOf(window), connector, flags]);
  518. }
  519. return windows;
  520. }
  521. _updateState() {
  522. const windows = this._collectWindows();
  523. const json = JSON.stringify(windows);
  524. if (json === this._windowsJson)
  525. return;
  526. this._windowsJson = json;
  527. this._windows = windows;
  528. this._dbus?.emit_signal('WindowsChanged', new GLib.Variant('(a(ssu))', [windows]));
  529. }
  530. }