Add support for disabling and restoring Cinnamon's built-in edge tiling
This commit is contained in:
45
extension.js
45
extension.js
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// uuid: ctile@ctile
|
// 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 Main = imports.ui.main;
|
||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
|
|
||||||
@@ -316,17 +316,32 @@ class TileOverlay {
|
|||||||
|
|
||||||
class CTileExtension {
|
class CTileExtension {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._overlay = null;
|
this._overlay = null;
|
||||||
this._dragWindow = null;
|
this._dragWindow = null;
|
||||||
this._pollId = null;
|
this._pollId = null;
|
||||||
this._grabbedLayout = null;
|
this._grabbedLayout = null;
|
||||||
this._grabBeginId = null;
|
this._grabBeginId = null;
|
||||||
this._grabEndId = null;
|
this._grabEndId = null;
|
||||||
this._stThemeChangedId = null;
|
this._stThemeChangedId = null;
|
||||||
this._gtkThemeChangedId = null;
|
this._gtkThemeChangedId = null;
|
||||||
|
this._muffinSettings = null;
|
||||||
|
this._savedEdgeTiling = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
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._overlay = new TileOverlay();
|
||||||
|
|
||||||
this._grabBeginId = global.display.connect(
|
this._grabBeginId = global.display.connect(
|
||||||
@@ -350,6 +365,18 @@ class CTileExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
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();
|
this._stopPoll();
|
||||||
if (this._grabBeginId) {
|
if (this._grabBeginId) {
|
||||||
global.display.disconnect(this._grabBeginId);
|
global.display.disconnect(this._grabBeginId);
|
||||||
|
|||||||
Reference in New Issue
Block a user