Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit daf5745

Browse files
lalochfaho
authored andcommitted
Initial support for activities
1 parent 13e2ec3 commit daf5745

File tree

3 files changed

+233
-64
lines changed

3 files changed

+233
-64
lines changed

contents/code/tile.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ function Tile(firstClient, tileIndex) {
6464
* desktop.
6565
*/
6666
this.desktopChanged = new Signal();
67+
/**
68+
* Signal which is triggered whenever the tile's presence across
69+
* activities changes. Two parameters are passed to the handlers, the
70+
* tile's current desktop and the tile's current screen.
71+
*/
72+
this.activitiesChanged = new Signal();
6773
/**
6874
* List of the clients in this tile.
6975
*/
@@ -94,6 +100,8 @@ function Tile(firstClient, tileIndex) {
94100
*/
95101
this._currentDesktop = util.getClientDesktop(firstClient);
96102

103+
this._activities = Array.from(firstClient.activities);
104+
97105
this.rectangle = null;
98106

99107
this.respectMinMax = KWin.readConfig("respectMinMax", true);
@@ -320,6 +328,29 @@ Tile.prototype.setClientGeometry = function(client) {
320328
}
321329
};
322330

331+
Tile.prototype.onClientActivitiesChanged = function(client) {
332+
try {
333+
var activities = Array.from(client.activities);
334+
var emit = false;
335+
if (this._activities.length == activities.length) {
336+
for (var i = 0; i < activities.length; i++) {
337+
if (!this._activities.includes(activities[i])) {
338+
emit = true;
339+
break;
340+
}
341+
}
342+
} else {
343+
emit = true;
344+
}
345+
if (emit) {
346+
this._activities = activities;
347+
this.activitiesChanged.emit();
348+
}
349+
} catch(err) {
350+
print(err, "in Tile.onClientActivitiesChanged");
351+
}
352+
};
353+
323354
Tile.prototype.onClientDesktopChanged = function(client) {
324355
try {
325356
var oldDesktop = this._currentDesktop;
@@ -432,24 +463,32 @@ Tile.prototype.hasClient = function(client) {
432463
return (this.clients.indexOf(client) > -1);
433464
};
434465

466+
Tile.prototype.getActivities = function() {
467+
return Array.from(this._activities);
468+
};
469+
435470
Tile.prototype.getDesktop = function() {
436471
return this._currentDesktop;
437-
}
472+
};
438473

439474
Tile.prototype.getScreen = function() {
440475
return this._currentScreen;
441-
}
476+
};
442477

443478
Tile.prototype.unmaximize = function() {
444479
if (this._canSetMaximize == true && this.maximized == true) {
445480
this.clients.forEach(function(c) {
446481
c.setMaximize(false, false);
447482
});
448483
}
449-
}
484+
};
450485

451486
Tile.prototype.setKeepBelow = function(setting) {
452487
this.clients.forEach(function(c) {
453488
c.keepBelow = setting;
454489
});
455-
}
490+
};
491+
492+
Tile.prototype.onAllActivities = function() {
493+
return this._activities.length == 0;
494+
};

contents/code/tilelist.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ TileList.prototype.connectSignals = function(client) {
171171
tile.onClientFinishUserMovedResized(client);
172172
}
173173
});
174+
client.activitiesChanged.connect(function(client) {
175+
var tile = getTile(client);
176+
if (tile != null) {
177+
tile.onClientActivitiesChanged(client);
178+
}
179+
});
174180
client.desktopChanged.connect(function() {
175181
var tile = getTile(client);
176182
if (tile != null) {

0 commit comments

Comments
 (0)