Add support for disabling and restoring Cinnamon's built-in edge tiling
This commit is contained in:
29
extension.js
29
extension.js
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// uuid: ctile@ctile
|
||||
|
||||
const { Clutter, St, Meta, GLib, Gtk } = imports.gi;
|
||||
const { Clutter, St, Meta, GLib, Gtk, Gio } = imports.gi;
|
||||
const Main = imports.ui.main;
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
@@ -324,9 +324,24 @@ class CTileExtension {
|
||||
this._grabEndId = null;
|
||||
this._stThemeChangedId = null;
|
||||
this._gtkThemeChangedId = null;
|
||||
this._muffinSettings = null;
|
||||
this._savedEdgeTiling = null;
|
||||
}
|
||||
|
||||
enable() {
|
||||
// Disable Cinnamon's built-in edge tiling so it doesn't conflict.
|
||||
try {
|
||||
this._muffinSettings = new Gio.Settings({ schema_id: 'org.cinnamon.muffin' });
|
||||
this._savedEdgeTiling = this._muffinSettings.get_boolean('edge-tiling');
|
||||
if (this._savedEdgeTiling)
|
||||
this._muffinSettings.set_boolean('edge-tiling', false);
|
||||
log(`built-in edge-tiling was ${this._savedEdgeTiling}, now disabled`);
|
||||
} catch(e) {
|
||||
log(`could not disable edge-tiling: ${e}`);
|
||||
this._muffinSettings = null;
|
||||
this._savedEdgeTiling = null;
|
||||
}
|
||||
|
||||
this._overlay = new TileOverlay();
|
||||
|
||||
this._grabBeginId = global.display.connect(
|
||||
@@ -350,6 +365,18 @@ class CTileExtension {
|
||||
}
|
||||
|
||||
disable() {
|
||||
// Restore the built-in edge tiling to whatever it was before we enabled.
|
||||
if (this._muffinSettings && this._savedEdgeTiling !== null) {
|
||||
try {
|
||||
this._muffinSettings.set_boolean('edge-tiling', this._savedEdgeTiling);
|
||||
log(`edge-tiling restored to ${this._savedEdgeTiling}`);
|
||||
} catch(e) {
|
||||
log(`could not restore edge-tiling: ${e}`);
|
||||
}
|
||||
}
|
||||
this._muffinSettings = null;
|
||||
this._savedEdgeTiling = null;
|
||||
|
||||
this._stopPoll();
|
||||
if (this._grabBeginId) {
|
||||
global.display.disconnect(this._grabBeginId);
|
||||
|
||||
Reference in New Issue
Block a user