Skip to content

Commit

Permalink
make mainloop event removed after disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
qunxyz committed Feb 7, 2018
1 parent 7f062e0 commit 799f1de
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions [email protected]/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ let ReasonUserApps;
let signalWindowCreatedId;
let signalWindowDestroyedId;
let signalInFullscreenId;
let mainloopFullScreenId;
let mainloopWindowId;

function init(ext) {
self = ext;
Expand All @@ -29,15 +31,15 @@ function init(ext) {
}));
// Enable caffeine when fullscreen app is running
if (self._settings.get_boolean(FULLSCREEN_KEY)) {
Mainloop.timeout_add_seconds(2, Lang.bind(self, function() {
mainloopFullScreenId = Mainloop.timeout_add_seconds(2, Lang.bind(self, function() {
// handle apps in fullcreen
signalInFullscreenId = global.screen.connect('in-fullscreen-changed', Lang.bind(self, function (screen) {
toggleFullscreen(screen.get_display().get_focus_window())
}));
}));
}

Mainloop.timeout_add_seconds(2, Lang.bind(self, function() {
mainloopWindowId = Mainloop.timeout_add_seconds(2, Lang.bind(self, function() {
global.get_window_actors().map(Lang.bind(self, function(actor) {
listenWindow(actor.meta_window);
}));
Expand Down Expand Up @@ -167,6 +169,9 @@ function kill() {
delete windows[index];
}
}

Mainloop.source_remove(mainloopFullScreenId);
Mainloop.source_remove(mainloopWindowId);
}


0 comments on commit 799f1de

Please sign in to comment.