69
72
this._workspaces[w].actor.reparent(this.actor);
70
73
this._workspaces[activeWorkspaceIndex].actor.raise_top();
72
this._extraWorkspaces = [];
73
let monitors = Main.layoutManager.monitors;
75
for (let i = 0; i < monitors.length; i++) {
76
if (i == Main.layoutManager.primaryIndex)
78
let ws = new Workspace.Workspace(null, i);
79
this._extraWorkspaces[m++] = ws;
80
ws.setGeometry(monitors[i].x, monitors[i].y, monitors[i].width, monitors[i].height);
81
global.overlay_group.add_actor(ws.actor);
75
this._updateExtraWorkspaces();
84
77
// Position/scale the desktop windows and their children after the
85
78
// workspaces have been created. This cannot be done first because
100
95
this._clipWidth, this._clipHeight);
103
this._scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
108
upper: this._workspaces.length });
109
this._scrollAdjustment.connect('notify::value',
110
Lang.bind(this, this._onScroll));
98
this.scrollAdjustment = new St.Adjustment({ value: activeWorkspaceIndex,
103
upper: this._workspaces.length });
104
this.scrollAdjustment.connect('notify::value',
105
Lang.bind(this, this._onScroll));
112
107
this._switchWorkspaceNotifyId =
113
108
global.window_manager.connect('switch-workspace',
121
116
Lang.bind(this, this._dragBegin));
122
117
this._windowDragEndId = Main.overview.connect('window-drag-end',
123
118
Lang.bind(this, this._dragEnd));
124
this._swipeScrollBeginId = 0;
125
this._swipeScrollEndId = 0;
121
_updateExtraWorkspaces: function() {
122
this._destroyExtraWorkspaces();
124
if (!this._settings.get_boolean('workspaces-only-on-primary'))
127
this._extraWorkspaces = [];
128
let monitors = Main.layoutManager.monitors;
129
for (let i = 0; i < monitors.length; i++) {
130
if (i == Main.layoutManager.primaryIndex)
133
let ws = new Workspace.Workspace(null, i);
134
ws.setGeometry(monitors[i].x, monitors[i].y,
135
monitors[i].width, monitors[i].height);
136
global.overlay_group.add_actor(ws.actor);
137
this._extraWorkspaces.push(ws);
141
_destroyExtraWorkspaces: function() {
142
if (!this._extraWorkspaces)
145
for (let m = 0; m < this._extraWorkspaces.length; m++)
146
this._extraWorkspaces[m].destroy();
147
this._extraWorkspaces = null;
128
150
setGeometry: function(x, y, width, height, spacing) {
452
462
_getWorkspaceIndexToRemove: function() {
453
463
return global.screen.get_active_workspace_index();
456
466
Signals.addSignalMethods(WorkspacesView.prototype);
459
function WorkspacesDisplay() {
469
const WorkspacesDisplay = new Lang.Class({
470
Name: 'WorkspacesDisplay',
463
WorkspacesDisplay.prototype = {
464
472
_init: function() {
465
473
this.actor = new Shell.GenericContainer();
466
474
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
467
475
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
468
476
this.actor.connect('allocate', Lang.bind(this, this._allocate));
477
this.actor.connect('notify::mapped', Lang.bind(this, this._setupSwipeScrolling));
478
this.actor.connect('parent-set', Lang.bind(this, this._parentSet));
469
479
this.actor.set_clip_to_allocation(true);
471
481
let controls = new St.Bin({ style_class: 'workspace-controls',
482
492
controls.connect('scroll-event',
483
493
Lang.bind(this, this._onScrollEvent));
485
this._monitorIndex = Main.layoutManager.primaryIndex;
495
this._primaryIndex = Main.layoutManager.primaryIndex;
487
497
this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox();
488
498
controls.add_actor(this._thumbnailsBox.actor);
490
this.workspacesView = null;
500
this._workspacesViews = null;
501
this._primaryScrollAdjustment = null;
503
this._settings = new Gio.Settings({ schema: OVERRIDE_SCHEMA });
504
this._settings.connect('changed::workspaces-only-on-primary',
506
this._workspacesOnlyOnPrimaryChanged));
507
this._workspacesOnlyOnPrimaryChanged();
492
509
this._inDrag = false;
493
510
this._cancelledDrag = false;
601
620
this._windowDragEndId = 0;
604
this.workspacesView.destroy();
605
this.workspacesView = null;
606
for (let w = 0; w < this._workspaces.length; w++) {
607
this._workspaces[w].disconnectAll();
608
this._workspaces[w].destroy();
623
for (let i = 0; i < this._workspacesViews.length; i++)
624
this._workspacesViews[i].destroy();
625
this._workspacesViews = null;
627
for (let i = 0; i < this._workspaces.length; i++)
628
for (let w = 0; w < this._workspaces[i].length; w++) {
629
this._workspaces[i][w].disconnectAll();
630
this._workspaces[i][w].destroy();
634
_setupSwipeScrolling: function() {
635
if (this._swipeScrollBeginId)
636
Main.overview.disconnect(this._swipeScrollBeginId);
637
this._swipeScrollBeginId = 0;
639
if (this._swipeScrollEndId)
640
Main.overview.disconnect(this._swipeScrollEndId);
641
this._swipeScrollEndId = 0;
643
if (!this.actor.mapped)
646
let direction = Overview.SwipeScrollDirection.VERTICAL;
647
Main.overview.setScrollAdjustment(this._scrollAdjustment,
649
this._swipeScrollBeginId = Main.overview.connect('swipe-scroll-begin',
650
Lang.bind(this, function() {
651
for (let i = 0; i < this._workspacesViews.length; i++)
652
this._workspacesViews[i].startSwipeScroll();
654
this._swipeScrollEndId = Main.overview.connect('swipe-scroll-end',
655
Lang.bind(this, function(overview, result) {
656
for (let i = 0; i < this._workspacesViews.length; i++)
657
this._workspacesViews[i].endSwipeScroll(result);
661
_workspacesOnlyOnPrimaryChanged: function() {
662
this._workspacesOnlyOnPrimary = this._settings.get_boolean('workspaces-only-on-primary');
664
if (!Main.overview.visible)
667
this._updateWorkspacesViews();
670
_updateWorkspacesViews: function() {
671
if (this._workspacesViews)
672
for (let i = 0; i < this._workspacesViews.length; i++)
673
this._workspacesViews[i].destroy();
675
if (this._workspaces)
676
for (let i = 0; i < this._workspaces.length; i++)
677
for (let w = 0; w < this._workspaces[i].length; w++)
678
this._workspaces[i][w].destroy();
680
this._workspacesViews = [];
681
this._workspaces = [];
682
let monitors = Main.layoutManager.monitors;
683
for (let i = 0; i < monitors.length; i++) {
684
if (this._workspacesOnlyOnPrimary && i != this._primaryIndex)
685
continue; // we are only interested in the primary monitor
687
let monitorWorkspaces = [];
688
for (let w = 0; w < global.screen.n_workspaces; w++) {
689
let metaWorkspace = global.screen.get_workspace_by_index(w);
690
monitorWorkspaces.push(new Workspace.Workspace(metaWorkspace, i));
693
this._workspaces.push(monitorWorkspaces);
695
let view = new WorkspacesView(monitorWorkspaces);
696
if (this._workspacesOnlyOnPrimary || i == this._primaryIndex) {
697
this._scrollAdjustment = view.scrollAdjustment;
698
this._scrollAdjustment.connect('notify::value',
699
Lang.bind(this, this._scrollValueChanged));
700
this._setupSwipeScrolling();
702
this._workspacesViews.push(view);
705
this._updateWorkspacesGeometry();
707
for (let i = 0; i < this._workspacesViews.length; i++)
708
global.overlay_group.add_actor(this._workspacesViews[i].actor);
711
_scrollValueChanged: function() {
712
if (this._workspacesOnlyOnPrimary)
715
for (let i = 0; i < this._workspacesViews.length; i++) {
716
if (i == this._primaryIndex)
719
let adjustment = this._workspacesViews[i].scrollAdjustment;
720
// the adjustments work in terms of workspaces, so the
721
// values map directly
722
adjustment.value = this._scrollAdjustment.value;
726
_getPrimaryView: function() {
727
if (!this._workspacesViews)
729
if (this._workspacesOnlyOnPrimary)
730
return this._workspacesViews[0];
732
return this._workspacesViews[this._primaryIndex];
735
activeWorkspaceHasMaximizedWindows: function() {
736
return this._getPrimaryView().getActiveWorkspace().hasMaximizedWindows();
612
739
// zoomFraction property allows us to tween the controls sliding in and out
679
806
this._updateWorkspacesGeometry();
809
_parentSet: function(actor, oldParent) {
810
if (oldParent && this._notifyOpacityId)
811
oldParent.disconnect(this._notifyOpacityId);
812
this._notifyOpacityId = 0;
814
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
816
let newParent = this.actor.get_parent();
820
// This is kinda hackish - we want the primary view to
821
// appear as parent of this.actor, though in reality it
822
// is added directly to overlay_group
823
this._notifyOpacityId = newParent.connect('notify::opacity',
824
Lang.bind(this, function() {
825
let opacity = this.actor.get_parent().opacity;
826
let primaryView = this._getPrimaryView();
829
primaryView.actor.opacity = opacity;
831
primaryView.actor.hide();
833
primaryView.actor.show();
682
838
_updateWorkspacesGeometry: function() {
683
if (!this.workspacesView)
839
if (!this._workspacesViews)
686
842
let fullWidth = this.actor.allocation.x2 - this.actor.allocation.x1;
717
871
let difference = fullHeight - height;
718
872
y += difference / 2;
720
this.workspacesView.setGeometry(x, y, width, height, difference);
875
let monitors = Main.layoutManager.monitors;
877
for (let i = 0; i < monitors.length; i++) {
878
if (i == this._primaryIndex) {
879
this._workspacesViews[m].setClipRect(clipX, clipY,
880
clipWidth, clipHeight);
881
this._workspacesViews[m].setGeometry(x, y, width, height,
884
} else if (!this._workspacesOnlyOnPrimary) {
885
this._workspacesViews[m].setClipRect(monitors[i].x,
889
this._workspacesViews[m].setGeometry(monitors[i].x,
892
monitors[i].height, 0);
723
898
_onRestacked: function() {
744
921
this._updateAlwaysZoom();
745
922
this._updateZoom();
747
if (this.workspacesView == null)
924
if (this._workspacesViews == null)
750
927
let lostWorkspaces = [];
751
928
if (newNumWorkspaces > oldNumWorkspaces) {
752
// Assume workspaces are only added at the end
753
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
754
let metaWorkspace = global.screen.get_workspace_by_index(w);
755
this._workspaces[w] = new Workspace.Workspace(metaWorkspace, this._monitorIndex);
929
let monitors = Main.layoutManager.monitors;
931
for (let i = 0; i < monitors.length; i++) {
932
if (this._workspacesOnlyOnPrimaryChanged &&
933
i != this._primaryIndex)
936
// Assume workspaces are only added at the end
937
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
938
let metaWorkspace = global.screen.get_workspace_by_index(w);
939
this._workspaces[m++][w] =
940
new Workspace.Workspace(metaWorkspace, i);
758
944
this._thumbnailsBox.addThumbnails(oldNumWorkspaces, newNumWorkspaces - oldNumWorkspaces);
763
949
let removedNum = oldNumWorkspaces - newNumWorkspaces;
764
950
for (let w = 0; w < oldNumWorkspaces; w++) {
765
951
let metaWorkspace = global.screen.get_workspace_by_index(w);
766
if (this._workspaces[w].metaWorkspace != metaWorkspace) {
952
if (this._workspaces[0][w].metaWorkspace != metaWorkspace) {
767
953
removedIndex = w;
772
lostWorkspaces = this._workspaces.splice(removedIndex,
958
for (let i = 0; i < this._workspaces.length; i++) {
959
lostWorkspaces = this._workspaces[i].splice(removedIndex,
775
for (let l = 0; l < lostWorkspaces.length; l++) {
776
lostWorkspaces[l].disconnectAll();
777
lostWorkspaces[l].destroy();
962
for (let l = 0; l < lostWorkspaces.length; l++) {
963
lostWorkspaces[l].disconnectAll();
964
lostWorkspaces[l].destroy();
780
968
this._thumbnailsBox.removeThumbmails(removedIndex, removedNum);
783
this.workspacesView.updateWorkspaces(oldNumWorkspaces,
971
for (let i = 0; i < this._workspacesViews.length; i++)
972
this._workspacesViews[i].updateWorkspaces(oldNumWorkspaces,
787
976
_updateZoom : function() {