Skip to content

Commit

Permalink
🐛 Complete fix crash when fullscreen/maximized window is closed directly
Browse files Browse the repository at this point in the history
The clientRemoved signal is too late in the window closing sequence, after
cleanGrouping called on the client. Moving the client around and changing focus requires a not null
in_group of the client in kwin. Therefore, changing to per window windowClosed signal works.
  • Loading branch information
Aetf committed Dec 15, 2018
1 parent f05bb5c commit efc212c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions contents/code/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function Main() {
log('handle maximize done');
},

removed: function(client) {
closed: function(client) {
log('handle remove');
self.state.debugDump();
if (!self.state.isKnownClient(client)) {
Expand Down Expand Up @@ -312,6 +312,11 @@ Main.prototype.popDesktop = function (pos) {
Main.prototype.moveToNewDesktop = function(client) {
this.state.savedDesktops[client.windowId] = client.desktop;

// register the client's windowClosed event
// we cannot use the global clientRemoved event, which is called
// after cleanGrouping of the client, and will cause crash of kwin
client.windowClosed.connect(this.handlers.closed);

var next = this.state.getNextDesktop(client);
this.insertDesktop(next);
client.desktop = next;
Expand All @@ -332,6 +337,9 @@ Main.prototype.moveBack = function(client, removed) {
var saved = this.state.savedDesktops[client.windowId];
delete this.state.savedDesktops[client.windowId];

// unregister the client's windowClosed event
client.windowClosed.disconnect(this.handlers.closed);

var toRemove = client.desktop;

log("Resotre client desktop to " + saved);
Expand All @@ -348,14 +356,12 @@ Main.prototype.moveBack = function(client, removed) {
Main.prototype.install = function() {
workspace.clientFullScreenSet.connect(this.handlers.fullscreen);
workspace.clientMaximizeSet.connect(this.handlers.maximize);
workspace.clientRemoved.connect(this.handlers.removed);
log("Handler installed");
}

Main.prototype.uninstall = function() {
workspace.clientFullScreenSet.disconnect(this.handlers.fullscreen);
workspace.clientMaximizeSet.disconnect(this.handlers.maximize);
workspace.clientRemoved.disconnect(this.handlers.removed);
log("Handler cleared");
}

Expand Down

0 comments on commit efc212c

Please sign in to comment.