Skip to content

Commit

Permalink
Remove workaround for GNOME Shell bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse authored and franglais125 committed Jul 25, 2017
1 parent 9295f70 commit 03cfa65
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 16 deletions.
41 changes: 25 additions & 16 deletions decoration.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Main = imports.ui.main;
const Mainloop = imports.mainloop;

const GLib = imports.gi.GLib;
const Meta = imports.gi.Meta;

const Config = imports.misc.config;
const Util = imports.misc.util;

const Me = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;

let showLog = false;
function LOG(message) {
Expand Down Expand Up @@ -33,6 +38,8 @@ const Decoration = new Lang.Class({
this.windowEnteredID = 0;
this.settings = settings;

this._shellVersion = Config.PACKAGE_VERSION;

this.enable();

this.changeMonitorsID = global.screen.connect(
Expand Down Expand Up @@ -313,21 +320,23 @@ const Decoration = new Lang.Class({
GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD,
null);

// After xprop completes, unmaximize and remaximize any window
// that is already maximized. It seems that setting the xprop on
// a window that is already maximized doesn't actually take
// effect immediately but it needs a focuse change or other
// action to force a relayout. Doing unmaximize and maximize
// here seems to be an uninvasive way to handle this. This needs
// to happen _after_ xprop completes.
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function () {
const MAXIMIZED = Meta.MaximizeFlags.BOTH;
let flags = win.get_maximized();
if (flags == MAXIMIZED) {
win.unmaximize(MAXIMIZED);
win.maximize(MAXIMIZED);
}
});
if (Utils.versionCompare(this._shellVersion, '3.24') < 0) {
// After xprop completes, unmaximize and remaximize any window
// that is already maximized. It seems that setting the xprop on
// a window that is already maximized doesn't actually take
// effect immediately but it needs a focuse change or other
// action to force a relayout. Doing unmaximize and maximize
// here seems to be an uninvasive way to handle this. This needs
// to happen _after_ xprop completes.
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function () {
const MAXIMIZED = Meta.MaximizeFlags.BOTH;
let flags = win.get_maximized();
if (flags == MAXIMIZED) {
win.unmaximize(MAXIMIZED);
win.maximize(MAXIMIZED);
}
});
}
},

/**** Callbacks ****/
Expand Down
36 changes: 36 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,39 @@ function onSizeChange(callback) {
return callbackIDs;
}

/** Compare two dotted version strings (like '10.2.3').
* @returns {Integer} 0: v1 == v2, -1: v1 < v2, 1: v1 > v2.
* Borrowed from system-monitor, https://github.com/paradoxxxzero/gnome-shell-system-monitor-applet
*/
function versionCompare(v1, v2) {
let v1parts = ('' + v1).split('.')
let v2parts = ('' + v2).split('.')
let minLength = Math.min(v1parts.length, v2parts.length)
let i, p1, p2;
// Compare tuple pair-by-pair.
for (i = 0; i < minLength; i++) {
// Convert to integer if possible, because "8" > "10".
p1 = parseInt(v1parts[i], 10);
p2 = parseInt(v2parts[i], 10);
if (isNaN(p1)) {
p1 = v1parts[i];
}
if (isNaN(p2)) {
p2 = v2parts[i];
}
if (p1 === p2) {
continue;
} else if (p1 > p2) {
return 1;
} else if (p1 < p2) {
return -1;
}
// one operand is NaN
return NaN;
}
// The longer tuple is always considered 'greater'
if (v1parts.length === v2parts.length) {
return 0;
}
return (v1parts.length < v2parts.length) ? -1 : 1;
}

0 comments on commit 03cfa65

Please sign in to comment.