Debian Codegraph @

extensions/window-list/extension.js

raw
1 // SPDX-FileCopyrightText: 2012 Florian Müllner <[email protected]>
2 // SPDX-FileCopyrightText: 2013 Giovanni Campagna <[email protected]>
3 // SPDX-FileCopyrightText: 2014 Sylvain Pasche <[email protected]>
4 //
5 // SPDX-License-Identifier: GPL-2.0-or-later
6
7 import Clutter from 'gi://Clutter';
8 import Gio from 'gi://Gio';
9 import GLib from 'gi://GLib';
10 import GObject from 'gi://GObject';
11 import Meta from 'gi://Meta';
12 import Mtk from 'gi://Mtk';
13 import Shell from 'gi://Shell';
14 import St from 'gi://St';
15
16 import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
17
18 import * as DND from 'resource:///org/gnome/shell/ui/dnd.js';
19 import * as Main from 'resource:///org/gnome/shell/ui/main.js';
20 import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
21 import {DashItemContainer} from 'resource:///org/gnome/shell/ui/dash.js';
22 import {
23 ANIMATION_TIME as SLIDE_ANIMATION_TIME,
24 } from 'resource:///org/gnome/shell/ui/overview.js';
25
26 import {WorkspaceIndicator} from './workspaceIndicator.js';
27
28 const ICON_TEXTURE_SIZE = 24;
29 const DND_ACTIVATE_TIMEOUT = 500;
30
31 const MIN_DRAG_UPDATE_INTERVAL = 500 * GLib.TIME_SPAN_MILLISECOND;
32
33 const DRAG_OPACITY = 0.3;
34 const DRAG_FADE_DURATION = 200;
35
36 const DRAG_RESIZE_DURATION = 400;
37
38 const DRAG_PROXIMITY_THRESHOLD = 30;
39
40 const SAVED_POSITIONS_KEY = 'window-list-positions';
41
42 const ATTENTION_INDICATOR_MAX_SCALE = 0.4;
43 const ATTENTION_INDICATOR_TRANSITION_DURATION = 300;
44
45 const GroupingMode = {
46 NEVER: 0,
47 AUTO: 1,
48 ALWAYS: 2,
49 };
50
51 class DragPlaceholderItem extends DashItemContainer {
52 static {
53 GObject.registerClass(this);
54 }
55
56 constructor() {
57 super();
58 this.setChild(new St.Bin({style_class: 'placeholder'}));
59 }
60 }
61
62 /**
63 * @param {Shell.App} app - an app
64 * @returns {number} - the smallest stable sequence of the app's windows
65 */
66 function _getAppStableSequence(app) {
67 const windows = app.get_windows().filter(w => !w.skip_taskbar);
68 return windows.reduce((prev, cur) => {
69 return Math.min(prev, cur.get_stable_sequence());
70 }, Infinity);
71 }
72
73 class WindowContextMenu extends PopupMenu.PopupMenu {
74 constructor(source, metaWindow) {
75 super(source, 0.5, St.Side.BOTTOM);
76
77 this._metaWindow = metaWindow;
78
79 this._minimizeItem = new PopupMenu.PopupMenuItem('');
80 this._minimizeItem.connect('activate', () => {
81 if (this._metaWindow.minimized)
82 this._metaWindow.unminimize();
83 else
84 this._metaWindow.minimize();
85 });
86 this.addMenuItem(this._minimizeItem);
87
88 this._maximizeItem = new PopupMenu.PopupMenuItem('');
89 this._maximizeItem.connect('activate', () => {
90 if (this._metaWindow.is_maximized())
91 this._metaWindow.unmaximize();
92 else
93 this._metaWindow.maximize();
94 });
95 this.addMenuItem(this._maximizeItem);
96
97 this._closeItem = new PopupMenu.PopupMenuItem(_('Close'));
98 this._closeItem.connect('activate', () => {
99 this._metaWindow.delete(global.get_current_time());
100 });
101 this.addMenuItem(this._closeItem);
102
103 this._metaWindow.connectObject(
104 'notify::minimized', this._updateMinimizeItem.bind(this),
105 'notify::maximized-horizontally', this._updateMaximizeItem.bind(this),
106 'notify::maximized-vertically', this._updateMaximizeItem.bind(this),
107 this.actor);
108
109 this._updateMinimizeItem();
110 this._updateMaximizeItem();
111
112 this.connect('open-state-changed', () => {
113 if (!this.isOpen)
114 return;
115
116 this._minimizeItem.setSensitive(this._metaWindow.can_minimize());
117 this._maximizeItem.setSensitive(this._metaWindow.can_maximize());
118 this._closeItem.setSensitive(this._metaWindow.can_close());
119 });
120 }
121
122 _updateMinimizeItem() {
123 this._minimizeItem.label.text = this._metaWindow.minimized
124 ? _('Unminimize') : _('Minimize');
125 }
126
127 _updateMaximizeItem() {
128 this._maximizeItem.label.text = this._metaWindow.is_maximized()
129 ? _('Unmaximize') : _('Maximize');
130 }
131 }
132
133 class TitleWidget extends St.Widget {
134 static {
135 GObject.registerClass({
136 GTypeFlags: GObject.TypeFlags.ABSTRACT,
137 Properties: {
138 'abstract-label': GObject.ParamSpec.boolean(
139 'abstract-label', null, null,
140 GObject.ParamFlags.READWRITE,
141 false),
142 },
143 }, this);
144 }
145
146 constructor() {
147 super({
148 layout_manager: new Clutter.BinLayout(),
149 x_expand: true,
150 y_expand: true,
151 });
152
153 const hbox = new St.BoxLayout({
154 style_class: 'window-button-box',
155 x_expand: true,
156 y_expand: true,
157 });
158 this.add_child(hbox);
159
160 this._icon = new St.Bin({
161 style_class: 'window-button-icon',
162 });
163 hbox.add_child(this._icon);
164
165 this._label = new St.Label({
166 y_align: Clutter.ActorAlign.CENTER,
167 });
168 hbox.add_child(this._label);
169 this.label_actor = this._label;
170
171 this.bind_property('abstract-label',
172 this._label, 'visible',
173 GObject.BindingFlags.SYNC_CREATE |
174 GObject.BindingFlags.INVERT_BOOLEAN);
175
176 this._abstractLabel = new St.Widget({
177 style_class: 'window-button-abstract-label',
178 x_expand: true,
179 y_expand: true,
180 });
181 hbox.add_child(this._abstractLabel);
182
183 this.bind_property('abstract-label',
184 this._abstractLabel, 'visible',
185 GObject.BindingFlags.SYNC_CREATE);
186
187 this._attentionIndicator = new St.Widget({
188 style_class: 'window-button-attention-indicator',
189 x_expand: true,
190 y_expand: true,
191 y_align: Clutter.ActorAlign.END,
192 scale_x: 0,
193 });
194 this._attentionIndicator.set_pivot_point(0.5, 0.5);
195 this.add_child(this._attentionIndicator);
196 }
197
198 setNeedsAttention(enable) {
199 this._attentionIndicator.ease({
200 scaleX: enable ? ATTENTION_INDICATOR_MAX_SCALE : 0,
201 duration: ATTENTION_INDICATOR_TRANSITION_DURATION,
202 });
203 }
204 }
205
206 class WindowTitle extends TitleWidget {
207 static {
208 GObject.registerClass(this);
209 }
210
211 constructor(metaWindow) {
212 super();
213
214 this._metaWindow = metaWindow;
215
216 this._metaWindow.connectObject(
217 'notify::wm-class',
218 () => this._updateIcon(), GObject.ConnectFlags.AFTER,
219 'notify::gtk-application-id',
220 () => this._updateIcon(), GObject.ConnectFlags.AFTER,
221 'notify::title', () => this._updateTitle(),
222 'notify::minimized', () => this._minimizedChanged(),
223 'notify::demands-attention', () => this._updateNeedsAttention(),
224 'notify::urgent', () => this._updateNeedsAttention(),
225 this);
226
227 this._updateIcon();
228 this._minimizedChanged();
229 this._updateNeedsAttention();
230 }
231
232 _minimizedChanged() {
233 this._icon.opacity = this._metaWindow.minimized ? 128 : 255;
234 this._updateTitle();
235 }
236
237 _updateNeedsAttention() {
238 const {urgent, demandsAttention} = this._metaWindow;
239 this.setNeedsAttention(urgent || demandsAttention);
240 }
241
242 _updateTitle() {
243 if (!this._metaWindow.title)
244 return;
245
246 if (this._metaWindow.minimized)
247 this._label.text = '[%s]'.format(this._metaWindow.title);
248 else
249 this._label.text = this._metaWindow.title;
250 }
251
252 _updateIcon() {
253 const app = Shell.WindowTracker.get_default().get_window_app(this._metaWindow);
254 if (app) {
255 this._icon.child = app.create_icon_texture(ICON_TEXTURE_SIZE);
256 } else {
257 this._icon.child = new St.Icon({
258 icon_name: 'application-x-executable',
259 icon_size: ICON_TEXTURE_SIZE,
260 });
261 }
262 }
263 }
264
265 class AppTitle extends TitleWidget {
266 static {
267 GObject.registerClass(this);
268 }
269
270 constructor(app) {
271 super();
272
273 this._app = app;
274 this._windows = new Set();
275
276 this._icon.child = app.create_icon_texture(ICON_TEXTURE_SIZE);
277 this._label.text = app.get_name();
278
279 this._app.connectObject(
280 'windows-changed', () => this._onWindowsChanged(),
281 this);
282 this._onWindowsChanged();
283
284 this.connect('destroy', () => {
285 console.debug(`Clearing windows of app ${this._app.id}`);
286 this._windows.clear();
287 });
288 }
289
290 _onWindowsChanged() {
291 const windows = this._app.get_windows();
292 const removed = [...this._windows].filter(w => !windows.includes(w));
293 removed.forEach(w => this._untrackWindow(w));
294 windows.forEach(w => this._trackWindow(w));
295 this._updateNeedsAttention();
296 }
297
298 _trackWindow(window) {
299 if (this._windows.has(window))
300 return;
301
302 console.debug(`Tracking window ${window} for app ${this._app.id}`);
303 window.connectObject(
304 'notify::urgent', () => this._updateNeedsAttention(),
305 'notify::demands-attention', () => this._updateNeedsAttention(),
306 this);
307 this._windows.add(window);
308 }
309
310 _untrackWindow(window) {
311 if (!this._windows.delete(window))
312 return;
313
314 console.debug(`Untracking window ${window} for app ${this._app.id}`);
315 window.disconnectObject(this);
316 }
317
318 _updateNeedsAttention() {
319 const needsAttention =
320 [...this._windows].some(w => w.urgent || w.demandsAttention);
321 this.setNeedsAttention(needsAttention);
322 }
323 }
324
325 class DragActor extends St.Bin {
326 static {
327 GObject.registerClass(this);
328 }
329
330 constructor(source, titleActor) {
331 super({
332 style_class: 'window-button-drag-actor',
333 child: titleActor,
334 width: source.width,
335 });
336
337 this.source = source;
338 }
339
340 setTargetWidth(width) {
341 const currentWidth = this.width;
342
343 // set width immediately so shell's DND code uses correct values
344 this.set({width});
345
346 // then transition from the original to the new width
347 const laters = global.compositor.get_laters();
348 laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
349 this.set({width: currentWidth});
350 this.ease({
351 width,
352 duration: DRAG_RESIZE_DURATION,
353 });
354 return GLib.SOURCE_REMOVE;
355 });
356 }
357 }
358
359 class BaseButton extends DashItemContainer {
360 static {
361 GObject.registerClass({
362 GTypeFlags: GObject.TypeFlags.ABSTRACT,
363 Properties: {
364 'ignore-workspace': GObject.ParamSpec.boolean(
365 'ignore-workspace', null, null,
366 GObject.ParamFlags.READWRITE,
367 false),
368 },
369 Signals: {
370 'drag-begin': {},
371 'drag-end': {},
372 },
373 }, this);
374 }
375
376 constructor(perMonitor, monitorIndex) {
377 super();
378
379 this._button = new St.Button({
380 style_class: 'window-button',
381 can_focus: true,
382 x_expand: true,
383 button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
384 });
385 this.setChild(this._button);
386
387 this._button.connect('notify::hover', () => {
388 if (this._button.hover)
389 this.showLabel();
390 else
391 this.hideLabel();
392 });
393
394 this._perMonitor = perMonitor;
395 this._monitorIndex = monitorIndex;
396 this._ignoreWorkspace = false;
397
398 this.connect('notify::allocation',
399 this._updateIconGeometry.bind(this));
400 this._button.connect('clicked', this._onClicked.bind(this));
401 this.connect('destroy', this._onDestroy.bind(this));
402 this.connect('popup-menu', this._onPopupMenu.bind(this));
403
404 this._contextMenuManager = new PopupMenu.PopupMenuManager(this);
405
406 global.window_manager.connectObject('switch-workspace',
407 () => this._updateVisibility(), this);
408
409 if (this._perMonitor) {
410 global.display.connectObject(
411 'window-entered-monitor',
412 this._windowEnteredOrLeftMonitor.bind(this),
413 'window-left-monitor',
414 this._windowEnteredOrLeftMonitor.bind(this),
415 this);
416 }
417
418 this._button._delegate = this;
419 this._draggable = DND.makeDraggable(this._button);
420 this._draggable.connect('drag-begin', () => {
421 this._removeLongPressTimeout();
422 this.emit('drag-begin');
423 });
424 this._draggable.connect('drag-cancelled', () => {
425 this._draggable._dragActor?.setTargetWidth(this.width);
426 this.emit('drag-end');
427 });
428 this._draggable.connect('drag-end', () => this.emit('drag-end'));
429 }
430
431 get active() {
432 return this._button.has_style_class_name('focused');
433 }
434
435 get ignore_workspace() {
436 return this._ignoreWorkspace;
437 }
438
439 set ignore_workspace(ignore) {
440 if (this._ignoreWorkspace === ignore)
441 return;
442
443 this._ignoreWorkspace = ignore;
444 this.notify('ignore-workspace');
445
446 this._updateVisibility();
447 }
448
449 showLabel() {
450 const [, , preferredTitleWidth] = this.label_actor.get_preferred_size();
451 const maxTitleWidth = this.label_actor.allocation.get_width();
452 const isTitleFullyShown = preferredTitleWidth <= maxTitleWidth;
453
454 const labelText = isTitleFullyShown
455 ? '' : this.label_actor.text;
456
457 this.setLabelText(labelText);
458 super.showLabel();
459 }
460
461 _setLongPressTimeout() {
462 if (this._longPressTimeoutId)
463 return;
464
465 const {longPressDuration} = Clutter.Settings.get_default();
466 this._longPressTimeoutId =
467 GLib.timeout_add_once(GLib.PRIORITY_DEFAULT, longPressDuration, () => {
468 delete this._longPressTimeoutId;
469
470 if (this._canOpenPopupMenu() && !this._contextMenu.isOpen)
471 this._openMenu(this._contextMenu);
472 });
473 }
474
475 _removeLongPressTimeout() {
476 if (!this._longPressTimeoutId)
477 return;
478 GLib.source_remove(this._longPressTimeoutId);
479 delete this._longPressTimeoutId;
480 }
481
482 vfunc_button_press_event(event) {
483 if (event.get_button() === 1)
484 this._setLongPressTimeout();
485 return super.vfunc_button_press_event(event);
486 }
487
488 vfunc_button_release_event(event) {
489 this._removeLongPressTimeout();
490
491 return super.vfunc_button_release_event(event);
492 }
493
494 vfunc_touch_event(event) {
495 if (event.type() === Clutter.EventType.TOUCH_BEGIN)
496 this._setLongPressTimeout();
497 else if (event.type() === Clutter.EventType.TOUCH_END)
498 this._removeLongPressTimeout();
499 return super.vfunc_touch_event(event);
500 }
501
502 activate() {
503 if (this.active)
504 return;
505
506 this._onClicked(this, 1);
507 }
508
509 getDragActor() {
510 const titleActor = this._createTitleActor();
511 titleActor.set({abstractLabel: true});
512
513 const dragActor = new DragActor(this, titleActor);
514
515 const [, natWidth] = this.get_preferred_width(-1);
516 const targetWidth = Math.min(natWidth / 2, this.width);
517 dragActor.setTargetWidth(targetWidth);
518
519 return dragActor;
520 }
521
522 getDragActorSource() {
523 return this;
524 }
525
526 _createTitleActor() {
527 throw new GObject.NotImplementedError(
528 `_createTitleActor in ${this.constructor.name}`);
529 }
530
531 _onClicked(_actor, _button) {
532 throw new GObject.NotImplementedError(
533 `_onClicked in ${this.constructor.name}`);
534 }
535
536 _canOpenPopupMenu() {
537 return true;
538 }
539
540 _openMenu(menu) {
541 menu.open();
542
543 const event = Clutter.get_current_event();
544 if (event && event.type() === Clutter.EventType.KEY_RELEASE)
545 menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
546 }
547
548 _minimizeOrActivateWindow(window) {
549 const focusWindow = global.display.focus_window;
550 if (focusWindow === window ||
551 focusWindow && focusWindow.get_transient_for() === window)
552 window.minimize();
553 else
554 window.activate(global.get_current_time());
555 }
556
557 _onPopupMenu(_actor) {
558 if (!this._canOpenPopupMenu() || this._contextMenu.isOpen)
559 return;
560 this._openMenu(this._contextMenu);
561 }
562
563 _isFocused() {
564 throw new GObject.NotImplementedError(
565 `_isFocused in ${this.constructor.name}`);
566 }
567
568 _updateStyle() {
569 if (this._isFocused())
570 this._button.add_style_class_name('focused');
571 else
572 this._button.remove_style_class_name('focused');
573 }
574
575 _windowEnteredOrLeftMonitor(_metaDisplay, _monitorIndex, _metaWindow) {
576 throw new GObject.NotImplementedError(
577 `_windowEnteredOrLeftMonitor in ${this.constructor.name}`);
578 }
579
580 _isWindowVisible(window) {
581 const workspace = global.workspace_manager.get_active_workspace();
582
583 return !window.skip_taskbar &&
584 (this._ignoreWorkspace || window.located_on_workspace(workspace)) &&
585 (!this._perMonitor || window.get_monitor() === this._monitorIndex);
586 }
587
588 _updateVisibility() {
589 throw new GObject.NotImplementedError(
590 `_updateVisibility in ${this.constructor.name}`);
591 }
592
593 _getIconGeometry() {
594 const rect = new Mtk.Rectangle();
595
596 [rect.x, rect.y] = this.get_transformed_position();
597 [rect.width, rect.height] = this.get_transformed_size();
598
599 return rect;
600 }
601
602 _updateIconGeometry() {
603 throw new GObject.NotImplementedError(
604 `_updateIconGeometry in ${this.constructor.name}`);
605 }
606
607 _onDestroy() {
608 }
609 }
610
611 class WindowButton extends BaseButton {
612 static {
613 GObject.registerClass(this);
614 }
615
616 constructor(metaWindow, perMonitor, monitorIndex) {
617 super(perMonitor, monitorIndex);
618
619 this.metaWindow = metaWindow;
620 this._unmanaging = false;
621 metaWindow.connectObject(
622 'notify::skip-taskbar', () => this._updateVisibility(),
623 'workspace-changed', () => this._updateVisibility(),
624 'unmanaging', () => (this._unmanaging = true),
625 this);
626
627 this._updateVisibility();
628
629 this._windowTitle = this._createTitleActor();
630 this._button.set_child(this._windowTitle);
631 this.label_actor = this._windowTitle.label_actor;
632
633 this._contextMenu = new WindowContextMenu(this, this.metaWindow);
634 this._contextMenu.actor.hide();
635 this._contextMenuManager.addMenu(this._contextMenu);
636 Main.uiGroup.add_child(this._contextMenu.actor);
637
638 global.display.connectObject('notify::focus-window',
639 () => this._updateStyle(), this);
640 this._updateStyle();
641 }
642
643 get id() {
644 return `window:${this.metaWindow.get_id()}`;
645 }
646
647 _createTitleActor() {
648 return new WindowTitle(this.metaWindow);
649 }
650
651 _onClicked(actor, button) {
652 if (this._contextMenu.isOpen) {
653 this._contextMenu.close();
654 return;
655 }
656
657 if (!button || button === 1)
658 this._minimizeOrActivateWindow(this.metaWindow);
659 else
660 this._openMenu(this._contextMenu);
661 }
662
663 _isFocused() {
664 return global.display.focus_window === this.metaWindow;
665 }
666
667 _updateStyle() {
668 super._updateStyle();
669
670 if (this.metaWindow.minimized)
671 this._button.add_style_class_name('minimized');
672 else
673 this._button.remove_style_class_name('minimized');
674 }
675
676 _windowEnteredOrLeftMonitor(metaDisplay, monitorIndex, metaWindow) {
677 if (monitorIndex === this._monitorIndex && metaWindow === this.metaWindow)
678 this._updateVisibility();
679 }
680
681 _updateVisibility() {
682 if (this._unmanaging)
683 return;
684
685 this.visible = this._isWindowVisible(this.metaWindow);
686 }
687
688 _updateIconGeometry() {
689 this.metaWindow.set_icon_geometry(this._getIconGeometry());
690 }
691
692 _onDestroy() {
693 super._onDestroy();
694 this._contextMenu.destroy();
695 }
696 }
697
698 class AppContextMenu extends PopupMenu.PopupMenu {
699 constructor(source) {
700 super(source, 0.5, St.Side.BOTTOM);
701
702 this._appButton = source;
703
704 this._minimizeItem = new PopupMenu.PopupMenuItem(_('Minimize all'));
705 this._minimizeItem.connect('activate', () => {
706 this._appButton.getWindowList().forEach(w => w.minimize());
707 });
708 this.addMenuItem(this._minimizeItem);
709
710 this._unminimizeItem = new PopupMenu.PopupMenuItem(_('Unminimize all'));
711 this._unminimizeItem.connect('activate', () => {
712 this._appButton.getWindowList().forEach(w => w.unminimize());
713 });
714 this.addMenuItem(this._unminimizeItem);
715
716 this._maximizeItem = new PopupMenu.PopupMenuItem(_('Maximize all'));
717 this._maximizeItem.connect('activate', () => {
718 this._appButton.getWindowList().forEach(w => {
719 w.maximize();
720 });
721 });
722 this.addMenuItem(this._maximizeItem);
723
724 this._unmaximizeItem = new PopupMenu.PopupMenuItem(_('Unmaximize all'));
725 this._unmaximizeItem.connect('activate', () => {
726 this._appButton.getWindowList().forEach(w => {
727 w.unmaximize();
728 });
729 });
730 this.addMenuItem(this._unmaximizeItem);
731
732 const item = new PopupMenu.PopupMenuItem(_('Close all'));
733 item.connect('activate', () => {
734 this._appButton.getWindowList().forEach(w => {
735 w.delete(global.get_current_time());
736 });
737 });
738 this.addMenuItem(item);
739 }
740
741 open(animate) {
742 const windows = this._appButton.getWindowList();
743 this._minimizeItem.visible = windows.some(w => !w.minimized);
744 this._unminimizeItem.visible = windows.some(w => w.minimized);
745 this._maximizeItem.visible = windows.some(w => {
746 return !w.is_maximized();
747 });
748 this._unmaximizeItem.visible = windows.some(w => {
749 return w.is_maximized();
750 });
751
752 super.open(animate);
753 }
754 }
755
756 class AppButton extends BaseButton {
757 static {
758 GObject.registerClass(this);
759 }
760
761 constructor(app, perMonitor, monitorIndex) {
762 super(perMonitor, monitorIndex);
763
764 this.app = app;
765 this._updateVisibility();
766
767 this._menuManager = new PopupMenu.PopupMenuManager(this);
768 this._menu = new PopupMenu.PopupMenu(this, 0.5, St.Side.BOTTOM);
769 this._menu.actor.hide();
770 this._menu.connect('activate', this._onMenuActivate.bind(this));
771 this._menuManager.addMenu(this._menu);
772 Main.uiGroup.add_child(this._menu.actor);
773
774 this.app.connectObject('windows-changed',
775 () => this._windowsChanged(), this);
776 this._windowsChanged();
777
778 this._windowTracker = Shell.WindowTracker.get_default();
779 this._windowTracker.connectObject('notify::focus-app',
780 () => this._updateStyle(), this);
781 this._updateStyle();
782 }
783
784 get id() {
785 return `app:${this.app.get_id()}`;
786 }
787
788 _windowEnteredOrLeftMonitor(metaDisplay, monitorIndex, metaWindow) {
789 if (this._windowTracker.get_window_app(metaWindow) === this.app &&
790 monitorIndex === this._monitorIndex) {
791 this._updateVisibility();
792 this._windowsChanged();
793 }
794 }
795
796 _updateVisibility() {
797 if (this._ignoreWorkspace) {
798 this.visible = true;
799 } else if (!this._perMonitor) {
800 // fast path: use ShellApp API to avoid iterating over all windows.
801 const workspace = global.workspace_manager.get_active_workspace();
802 this.visible = this.app.is_on_workspace(workspace);
803 } else {
804 this.visible = this.getWindowList().length >= 1;
805 }
806 }
807
808 _isFocused() {
809 return this._windowTracker.focus_app === this.app;
810 }
811
812 _updateIconGeometry() {
813 const rect = this._getIconGeometry();
814
815 const windows = this.app.get_windows();
816 windows.forEach(w => w.set_icon_geometry(rect));
817 }
818
819 getWindowList() {
820 return this.app.get_windows().filter(win => this._isWindowVisible(win));
821 }
822
823 _windowsChanged() {
824 const windows = this.getWindowList();
825 const singleWindowMode = windows.length === 1;
826
827 if (this._singleWindowMode === singleWindowMode)
828 return;
829
830 this._singleWindowMode = singleWindowMode;
831
832 this._button.child?.destroy();
833 this._contextMenu?.destroy();
834
835 if (this._singleWindowMode) {
836 const [window] = windows;
837 this._contextMenu = new WindowContextMenu(this, window);
838 } else {
839 this._contextMenu = new AppContextMenu(this);
840 }
841
842 this._button.child = this._createTitleActor();
843 this.label_actor = this._button.child.label_actor;
844
845 Main.uiGroup.add_child(this._contextMenu.actor);
846 this._contextMenu.actor.hide();
847 this._contextMenuManager.addMenu(this._contextMenu);
848 }
849
850 _createTitleActor() {
851 if (this._singleWindowMode) {
852 const [window] = this.getWindowList();
853 return new WindowTitle(window);
854 } else {
855 return new AppTitle(this.app);
856 }
857 }
858
859 _onClicked(actor, button) {
860 const menuWasOpen = this._menu.isOpen;
861 if (menuWasOpen)
862 this._menu.close();
863
864 const contextMenuWasOpen = this._contextMenu.isOpen;
865 if (contextMenuWasOpen)
866 this._contextMenu.close();
867
868 if (!button || button === 1) {
869 if (menuWasOpen)
870 return;
871
872 const windows = this.getWindowList();
873 if (windows.length === 1) {
874 if (contextMenuWasOpen)
875 return;
876 this._minimizeOrActivateWindow(windows[0]);
877 } else {
878 this._menu.removeAll();
879
880 for (let i = 0; i < windows.length; i++) {
881 const windowTitle = new WindowTitle(windows[i]);
882 const item = new PopupMenu.PopupBaseMenuItem();
883 item.add_child(windowTitle);
884 item._window = windows[i];
885 this._menu.addMenuItem(item);
886 }
887 this._openMenu(this._menu);
888 }
889 } else {
890 if (contextMenuWasOpen)
891 return;
892 this._openMenu(this._contextMenu);
893 }
894 }
895
896 _canOpenPopupMenu() {
897 return !this._menu.isOpen;
898 }
899
900 _onMenuActivate(menu, child) {
901 child._window.activate(global.get_current_time());
902 }
903
904 _onDestroy() {
905 super._onDestroy();
906 this._menu.destroy();
907 }
908 }
909
910 class WindowList extends St.Widget {
911 static {
912 GObject.registerClass(this);
913 }
914
915 constructor(perMonitor, monitor, extension) {
916 super({
917 name: 'panel',
918 style_class: 'bottom-panel solid',
919 reactive: true,
920 track_hover: true,
921 layout_manager: new Clutter.BinLayout(),
922 });
923 this.connect('destroy', this._onDestroy.bind(this));
924
925 this._perMonitor = perMonitor;
926 this._monitor = monitor;
927
928 const box = new St.BoxLayout({x_expand: true, y_expand: true});
929 this.add_child(box);
930
931 this._windowList = new St.BoxLayout({
932 style_class: 'window-list',
933 reactive: true,
934 x_align: Clutter.ActorAlign.START,
935 x_expand: true,
936 y_expand: true,
937 });
938 box.add_child(this._windowList);
939
940 this._windowList.connect('scroll-event', this._onScrollEvent.bind(this));
941
942 const indicatorsBox = new St.BoxLayout({x_align: Clutter.ActorAlign.END});
943 box.add_child(indicatorsBox);
944
945 this._workspaceIndicator = new BottomWorkspaceIndicator({
946 baseStyleClass: 'window-list-workspace-indicator',
947 extension,
948 });
949 indicatorsBox.add_child(this._workspaceIndicator.container);
950
951 this._mutterSettings = new Gio.Settings({schema_id: 'org.gnome.mutter'});
952 this._mutterSettings.connectObject(
953 'changed::workspaces-only-on-primary',
954 () => this._updateWorkspaceIndicatorVisibility(),
955 'changed::dynamic-workspaces',
956 () => this._updateWorkspaceIndicatorVisibility(),
957 this);
958 this._updateWorkspaceIndicatorVisibility();
959
960 this._menuManager = new PopupMenu.PopupMenuManager(this);
961 this._workspaceIndicator.connectObject('menu-set',
962 () => this._onWorkspaceMenuSet(), this);
963 this._onWorkspaceMenuSet();
964
965 const inOverview = Main.overview.visible ||
966 (Main.layoutManager._startingUp && Main.sessionMode.hasOverview);
967
968 const overviewChromeOptions = {
969 affectsStruts: true,
970 };
971 const chromeOptions = {
972 ...overviewChromeOptions,
973 trackFullscreen: true,
974 };
975 Main.layoutManager.addChrome(this, inOverview
976 ? overviewChromeOptions
977 : chromeOptions);
978
979 Main.uiGroup.set_child_above_sibling(this, Main.layoutManager.panelBox);
980 Main.ctrlAltTabManager.addGroup(this, _('Window List'), 'start-here-symbolic');
981
982 this.visible = !inOverview;
983
984 this.width = this._monitor.width;
985 this.connect('notify::height', this._updatePosition.bind(this));
986 this._updatePosition();
987
988 this._appSystem = Shell.AppSystem.get_default();
989 this._appSystem.connectObject('app-state-changed',
990 this._onAppStateChanged.bind(this), this);
991
992 // Hack: OSK gesture is tied to visibility, piggy-back on that
993 Main.keyboard._bottomDragGesture.connectObject('notify::enabled',
994 action => {
995 const visible = !action.enabled;
996 if (visible) {
997 Main.uiGroup.set_child_above_sibling(
998 this, Main.layoutManager.keyboardBox);
999 } else {
1000 Main.uiGroup.set_child_above_sibling(
1001 this, Main.layoutManager.panelBox);
1002 }
1003 this._updateKeyboardAnchor();
1004 }, this);
1005
1006 const workspaceManager = global.workspace_manager;
1007
1008 workspaceManager.connectObject('notify::n-workspaces',
1009 () => this._updateWorkspaceIndicatorVisibility(), this);
1010 this._updateWorkspaceIndicatorVisibility();
1011
1012 global.window_manager.connectObject('switch-workspace',
1013 () => this._checkGrouping(), this);
1014
1015 Main.overview.connectObject(
1016 'showing', () => {
1017 this._retrackChrome(overviewChromeOptions);
1018 this._slideOut();
1019 this._updateKeyboardAnchor();
1020 },
1021 'hiding', () => {
1022 if (!this._monitor.inFullscreen)
1023 this._slideIn();
1024 },
1025 'hidden', () => {
1026 this._retrackChrome(chromeOptions);
1027 this._updateKeyboardAnchor();
1028 }, this);
1029
1030 global.display.connectObject('in-fullscreen-changed', () => {
1031 this._updateKeyboardAnchor();
1032 }, this);
1033
1034 this._windowSignals = new Map();
1035 global.display.connectObject(
1036 'window-created', (dsp, win) => this._addWindow(win, true), this);
1037
1038 Main.xdndHandler.connectObject(
1039 'drag-begin', () => this._monitorXdndDrag(),
1040 'drag-end', () => this._stopMonitoringXdndDrag(),
1041 this);
1042
1043 this._xdndDragMonitor = {
1044 dragMotion: this._onXdndDragMotion.bind(this),
1045 };
1046
1047 this._itemDragMonitor = {
1048 dragMotion: this._onItemDragMotion.bind(this),
1049 dragDrop: this._onItemDragDrop.bind(this),
1050 };
1051
1052 this._dndTimeoutId = 0;
1053 this._dndWindow = null;
1054
1055 this._dragPlaceholder = null;
1056 this._dragPlaceholderPos = -1;
1057 this._lastPlaceholderUpdate = 0;
1058
1059 this._delegate = this;
1060
1061 this._settings = extension.getSettings();
1062 this._settings.connectObject('changed::grouping-mode',
1063 () => this._groupingModeChanged(), this);
1064 this._grouped = undefined;
1065 this._groupingModeChanged();
1066 }
1067
1068 get_transformed_position() {
1069 // HACK: Remove translation we use for animations
1070 // to keep struts stable
1071 const [x, y] = super.get_transformed_position();
1072 return [x, y - this.translation_y];
1073 }
1074
1075 _onScrollEvent(actor, event) {
1076 const direction = event.get_scroll_direction();
1077 let diff = 0;
1078 if (direction === Clutter.ScrollDirection.DOWN)
1079 diff = 1;
1080 else if (direction === Clutter.ScrollDirection.UP)
1081 diff = -1;
1082 else
1083 return;
1084
1085 const children = this._windowList.get_children()
1086 .filter(c => c.visible);
1087 const active = children.findIndex(c => c.active);
1088 const newActive = Math.max(0, Math.min(active + diff, children.length - 1));
1089 children[newActive].activate();
1090 }
1091
1092 _onWorkspaceMenuSet() {
1093 if (this._workspaceIndicator.menu)
1094 this._menuManager.addMenu(this._workspaceIndicator.menu);
1095 }
1096
1097 _updatePosition() {
1098 this.set_position(
1099 this._monitor.x,
1100 this._monitor.y + this._monitor.height - this.height);
1101 }
1102
1103 _retrackChrome(options) {
1104 Main.layoutManager.untrackChrome(this);
1105 Main.layoutManager.trackChrome(this, options);
1106 }
1107
1108 _slideIn() {
1109 this.show();
1110 this.ease({
1111 translation_y: 0,
1112 duration: SLIDE_ANIMATION_TIME,
1113 mode: Clutter.AnimationMode.EASE_OUT_QUAD,
1114 });
1115 }
1116
1117 _slideOut() {
1118 this.ease({
1119 translation_y: this.height,
1120 duration: SLIDE_ANIMATION_TIME,
1121 mode: Clutter.AnimationMode.EASE_OUT_QUAD,
1122 onComplete: () => this.hide(),
1123 });
1124 }
1125
1126 _updateWorkspaceIndicatorVisibility() {
1127 const workspaceManager = global.workspace_manager;
1128 const hasWorkspaces = this._mutterSettings.get_boolean('dynamic-workspaces') ||
1129 workspaceManager.n_workspaces > 1;
1130 const workspacesOnMonitor = this._monitor === Main.layoutManager.primaryMonitor ||
1131 !this._mutterSettings.get_boolean('workspaces-only-on-primary');
1132
1133 this._workspaceIndicator.visible = hasWorkspaces && workspacesOnMonitor;
1134 }
1135
1136 _getPreferredUngroupedWindowListWidth() {
1137 if (this._windowList.get_n_children() === 0)
1138 return this._windowList.get_preferred_width(-1)[1];
1139
1140 const children = this._windowList.get_children();
1141 const [, childWidth] = children[0].get_preferred_width(-1);
1142 const {spacing} = this._windowList.layout_manager;
1143
1144 const workspace = global.workspace_manager.get_active_workspace();
1145 let windows = global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
1146 if (this._perMonitor)
1147 windows = windows.filter(w => w.get_monitor() === this._monitor.index);
1148 const nWindows = windows.length;
1149 if (nWindows === 0)
1150 return this._windowList.get_preferred_width(-1)[1];
1151
1152 return nWindows * childWidth + (nWindows - 1) * spacing;
1153 }
1154
1155 _getMaxWindowListWidth() {
1156 const indicatorsBox = this._workspaceIndicator.get_parent();
1157 return this.width - indicatorsBox.get_preferred_width(-1)[1];
1158 }
1159
1160 _groupingModeChanged() {
1161 this._groupingMode = this._settings.get_enum('grouping-mode');
1162
1163 if (this._groupingMode === GroupingMode.AUTO) {
1164 this._checkGrouping();
1165 } else {
1166 this._grouped = this._groupingMode === GroupingMode.ALWAYS;
1167 this._populateWindowList();
1168 }
1169 }
1170
1171 _checkGrouping() {
1172 if (this._groupingMode !== GroupingMode.AUTO)
1173 return;
1174
1175 const maxWidth = this._getMaxWindowListWidth();
1176 const natWidth = this._getPreferredUngroupedWindowListWidth();
1177
1178 const grouped = maxWidth < natWidth;
1179 if (this._grouped !== grouped) {
1180 this._grouped = grouped;
1181 this._populateWindowList();
1182 }
1183 }
1184
1185 _populateWindowList() {
1186 this._windowList.destroy_all_children();
1187
1188 if (!this._grouped) {
1189 const windows = global.get_window_actors().sort((w1, w2) => {
1190 return w1.metaWindow.get_stable_sequence() -
1191 w2.metaWindow.get_stable_sequence();
1192 });
1193 for (let i = 0; i < windows.length; i++)
1194 this._addWindow(windows[i].metaWindow, false);
1195 } else {
1196 const apps = this._appSystem.get_running().sort((a1, a2) => {
1197 return _getAppStableSequence(a1) -
1198 _getAppStableSequence(a2);
1199 });
1200 for (let i = 0; i < apps.length; i++)
1201 this._addApp(apps[i], false);
1202 }
1203
1204 this._restorePositions();
1205 }
1206
1207 _updateKeyboardAnchor() {
1208 const translationY = Main.overview.visible ? 0 : this.height;
1209 Main.layoutManager.keyboardBox.translation_y = -translationY;
1210 }
1211
1212 _onAppStateChanged(appSys, app) {
1213 if (!this._grouped)
1214 return;
1215
1216 if (app.state === Shell.AppState.RUNNING)
1217 this._addApp(app, true);
1218 else if (app.state === Shell.AppState.STOPPED)
1219 this._removeApp(app);
1220 }
1221
1222 _addButton(button, animate) {
1223 this._settings.bind('display-all-workspaces',
1224 button, 'ignore-workspace', Gio.SettingsBindFlags.GET);
1225
1226 button.connect('drag-begin', () => {
1227 button.ease({
1228 opacity: 255 * DRAG_OPACITY,
1229 duration: DRAG_FADE_DURATION,
1230 });
1231
1232 this._monitorItemDrag();
1233 });
1234 button.connect('drag-end', () => {
1235 button.ease({
1236 opacity: 255,
1237 duration: DRAG_FADE_DURATION,
1238 });
1239
1240 this._stopMonitoringItemDrag();
1241 this._clearDragPlaceholder();
1242 });
1243
1244 this._windowList.add_child(button);
1245 button.show(animate);
1246 }
1247
1248 _addApp(app, animate) {
1249 const button = new AppButton(app, this._perMonitor, this._monitor.index);
1250 this._addButton(button, animate);
1251 }
1252
1253 _removeApp(app) {
1254 const children = this._windowList.get_children();
1255 const child = children.find(c => c.app === app);
1256 child?.animateOutAndDestroy();
1257 }
1258
1259 _addWindow(win, animate) {
1260 if (!this._grouped)
1261 this._checkGrouping();
1262
1263 if (this._grouped)
1264 return;
1265
1266 const children = this._windowList.get_children();
1267 if (children.find(c => c.metaWindow === win))
1268 return;
1269
1270 this._windowSignals.set(
1271 win, win.connect('unmanaged', () => this._removeWindow(win)));
1272
1273 const button = new WindowButton(win, this._perMonitor, this._monitor.index);
1274 this._addButton(button, animate);
1275 }
1276
1277 _removeWindow(win) {
1278 if (this._grouped)
1279 this._checkGrouping();
1280
1281 if (this._grouped)
1282 return;
1283
1284 const id = this._windowSignals.get(win);
1285 if (id)
1286 win.disconnect(id);
1287 this._windowSignals.delete(win);
1288
1289 const children = this._windowList.get_children();
1290 const child = children.find(c => c.metaWindow === win);
1291 child?.animateOutAndDestroy();
1292 }
1293
1294 _clearDragPlaceholder() {
1295 this._dragPlaceholder?.animateOutAndDestroy();
1296 this._dragPlaceholder = null;
1297 this._dragPlaceholderPos = -1;
1298 }
1299
1300 handleDragOver(source, _actor, x, _y, _time) {
1301 if (!(source instanceof BaseButton))
1302 return DND.DragMotionResult.NO_DROP;
1303
1304 const buttons = this._windowList.get_children().filter(c => c instanceof BaseButton);
1305 const buttonPos = buttons.indexOf(source);
1306 const numButtons = buttons.length;
1307 const boxWidth = this._windowList.width;
1308
1309 // Transform to window list coordinates for index calculation
1310 // (mostly relevant for RTL to discard workspace indicator etc.)
1311 x -= this._windowList.x;
1312
1313 const rtl = this.text_direction === Clutter.TextDirection.RTL;
1314 let pos = rtl
1315 ? numButtons - Math.round(x * numButtons / boxWidth)
1316 : Math.round(x * numButtons / boxWidth);
1317
1318 pos = Math.clamp(pos, 0, numButtons);
1319
1320 const timeDelta =
1321 GLib.get_monotonic_time() - this._lastPlaceholderUpdate;
1322
1323 if (pos !== this._dragPlaceholderPos && timeDelta >= MIN_DRAG_UPDATE_INTERVAL) {
1324 this._clearDragPlaceholder();
1325 this._dragPlaceholderPos = pos;
1326
1327 this._lastPlaceholderUpdate = GLib.get_monotonic_time();
1328
1329 // Don't allow positioning before or after self
1330 if (pos === buttonPos || pos === buttonPos + 1)
1331 return DND.DragMotionResult.CONTINUE;
1332
1333 this._dragPlaceholder = new DragPlaceholderItem();
1334 const sibling = buttons[pos] ?? null;
1335 if (sibling)
1336 this._windowList.insert_child_below(this._dragPlaceholder, sibling);
1337 else
1338 this._windowList.insert_child_above(this._dragPlaceholder, null);
1339 this._dragPlaceholder.show(true);
1340 }
1341
1342 return this._dragPlaceholder
1343 ? DND.DragMotionResult.MOVE_DROP
1344 : DND.DragMotionResult.NO_DROP;
1345 }
1346
1347 acceptDrop(source, _actor, _x, _y, _time) {
1348 if (this._dragPlaceholderPos >= 0)
1349 this._windowList.set_child_at_index(source, this._dragPlaceholderPos);
1350
1351 this._clearDragPlaceholder();
1352
1353 this._savePositions();
1354
1355 return true;
1356 }
1357
1358 _getPositionStateKey() {
1359 return `${SAVED_POSITIONS_KEY}:${this._monitor.index}`;
1360 }
1361
1362 _savePositions() {
1363 const buttons = this._windowList.get_children()
1364 .filter(b => b instanceof BaseButton);
1365 global.set_runtime_state(this._getPositionStateKey(),
1366 new GLib.Variant('as', buttons.map(b => b.id)));
1367 }
1368
1369 _restorePositions() {
1370 const positions = global.get_runtime_state('as',
1371 this._getPositionStateKey())?.deepUnpack() ?? [];
1372
1373 for (const button of this._windowList.get_children()) {
1374 const pos = positions.indexOf(button.id);
1375 if (pos > -1)
1376 this._windowList.set_child_at_index(button, pos);
1377 }
1378 }
1379
1380 _monitorItemDrag() {
1381 DND.addDragMonitor(this._itemDragMonitor);
1382 }
1383
1384 _stopMonitoringItemDrag() {
1385 DND.removeDragMonitor(this._itemDragMonitor);
1386 }
1387
1388 _onItemDragMotion(dragEvent) {
1389 const {source, targetActor, dragActor, x, y} = dragEvent;
1390
1391 const hasTarget = this._windowList.contains(targetActor);
1392 const isNear = Math.abs(y - this.y) < DRAG_PROXIMITY_THRESHOLD;
1393
1394 if (hasTarget || isNear)
1395 return this.handleDragOver(source, dragActor, x, y);
1396
1397 this._clearDragPlaceholder();
1398 return DND.DragMotionResult.CONTINUE;
1399 }
1400
1401 _onItemDragDrop(dropEvent) {
1402 if (this._dragPlaceholderPos < 0)
1403 return DND.DragDropResult.CONTINUE;
1404
1405 const {source} = dropEvent.dropActor;
1406 this.acceptDrop(source);
1407 dropEvent.dropActor.destroy();
1408 // HACK: SUCESS would make more sense, but results in gnome-shell
1409 // skipping all drag-end code
1410 return DND.DragDropResult.CONTINUE;
1411 }
1412
1413 _monitorXdndDrag() {
1414 DND.addDragMonitor(this._xdndDragMonitor);
1415 }
1416
1417 _stopMonitoringXdndDrag() {
1418 DND.removeDragMonitor(this._xdndDragMonitor);
1419 this._removeActivateTimeout();
1420 }
1421
1422 _onXdndDragMotion(dragEvent) {
1423 if (Main.overview.visible ||
1424 !this.contains(dragEvent.targetActor)) {
1425 this._removeActivateTimeout();
1426 return DND.DragMotionResult.CONTINUE;
1427 }
1428
1429 const hoveredWindow = dragEvent.targetActor.metaWindow;
1430 if (!hoveredWindow ||
1431 this._dndWindow === hoveredWindow)
1432 return DND.DragMotionResult.CONTINUE;
1433
1434 this._removeActivateTimeout();
1435
1436 this._dndWindow = hoveredWindow;
1437 this._dndTimeoutId = GLib.timeout_add_once(GLib.PRIORITY_DEFAULT,
1438 DND_ACTIVATE_TIMEOUT, this._activateWindow.bind(this));
1439
1440 return DND.DragMotionResult.CONTINUE;
1441 }
1442
1443 _removeActivateTimeout() {
1444 if (this._dndTimeoutId)
1445 GLib.source_remove(this._dndTimeoutId);
1446 this._dndTimeoutId = 0;
1447 this._dndWindow = null;
1448 }
1449
1450 _activateWindow() {
1451 const [x, y] = global.get_pointer();
1452 const pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.ALL, x, y);
1453
1454 if (this._dndWindow && this.contains(pickedActor))
1455 this._dndWindow.activate(global.get_current_time());
1456 this._dndWindow = null;
1457 this._dndTimeoutId = 0;
1458 }
1459
1460 _onDestroy() {
1461 this._workspaceIndicator.destroy();
1462
1463 Main.ctrlAltTabManager.removeGroup(this);
1464
1465 this._windowSignals.forEach((id, win) => win.disconnect(id));
1466 this._windowSignals.clear();
1467
1468 this._stopMonitoringXdndDrag();
1469
1470 this._settings.disconnectObject();
1471 this._settings = null;
1472
1473 const windows = global.get_window_actors();
1474 for (let i = 0; i < windows.length; i++)
1475 windows[i].metaWindow.set_icon_geometry(null);
1476 }
1477 }
1478
1479 class BottomWorkspaceIndicator extends WorkspaceIndicator {
1480 static {
1481 GObject.registerClass(this);
1482 }
1483
1484 setMenu(menu) {
1485 super.setMenu(menu);
1486
1487 if (!menu)
1488 return;
1489
1490 this.menu.actor.updateArrowSide(St.Side.BOTTOM);
1491 this.menu.actor.remove_style_class_name('panel-menu');
1492 }
1493 }
1494
1495 export default class WindowListExtension extends Extension {
1496 constructor(metadata) {
1497 super(metadata);
1498
1499 this._windowLists = null;
1500 }
1501
1502 enable() {
1503 this._windowLists = [];
1504
1505 this._settings = this.getSettings();
1506 this._settings.connectObject('changed::show-on-all-monitors',
1507 () => this._buildWindowLists(), this);
1508
1509 Main.layoutManager.connectObject('monitors-changed',
1510 () => this._buildWindowLists(), this);
1511
1512 this._buildWindowLists();
1513 }
1514
1515 _buildWindowLists() {
1516 this._windowLists.forEach(list => list.destroy());
1517 this._windowLists = [];
1518
1519 const showOnAllMonitors = this._settings.get_boolean('show-on-all-monitors');
1520
1521 Main.layoutManager.monitors.forEach(monitor => {
1522 if (showOnAllMonitors || monitor === Main.layoutManager.primaryMonitor)
1523 this._windowLists.push(new WindowList(showOnAllMonitors, monitor, this));
1524 });
1525 }
1526
1527 disable() {
1528 if (!this._windowLists)
1529 return;
1530
1531 Main.layoutManager.disconnectObject(this);
1532 this._settings.disconnectObject(this);
1533 this._settings = null;
1534
1535 this._windowLists.forEach(windowList => {
1536 windowList.hide();
1537 windowList.destroy();
1538 });
1539 this._windowLists = null;
1540 }
1541 }