Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnome-shell 3.36.1 compatibility #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions [email protected]/indicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,27 @@ var WindowCornerIndicator = new Lang.Class({

// 3b, Zoom slider
this.menuZoom = new PopupSliderMenuItem(false, DEFAULT_ZOOM, MIN_ZOOM, MAX_ZOOM, 0.005); // slider step: 0.5%
this.menuZoom.connect("value-changed", Lang.bind(this, this._onZoomChanged));
this.menuZoom._streamEvents.connect("notify::value", Lang.bind(this, this._onZoomChanged));
this.menu.addMenuItem(this.menuZoom);

// 4. Crop Sliders
this.menuCrop = new PopupMenu.PopupSubMenuMenuItem("Crop");
this.menu.addMenuItem(this.menuCrop);

this.menuTopCrop = new PopupSliderMenuItem("Top", DEFAULT_CROP_RATIO, 0.0, MAX_CROP_RATIO);
this.menuTopCrop.connect("value-changed", Lang.bind(this, this._onTopCropChanged));
this.menuTopCrop._streamEvents.connect("notify::value", Lang.bind(this, this._onTopCropChanged));
this.menuCrop.menu.addMenuItem(this.menuTopCrop);

this.menuLeftCrop = new PopupSliderMenuItem("Left", DEFAULT_CROP_RATIO, 0.0, MAX_CROP_RATIO);
this.menuLeftCrop.connect("value-changed", Lang.bind(this, this._onLeftCropChanged));
this.menuLeftCrop._streamEvents.connect("notify::value", Lang.bind(this, this._onLeftCropChanged));
this.menuCrop.menu.addMenuItem(this.menuLeftCrop);

this.menuRightCrop = new PopupSliderMenuItem("Right", DEFAULT_CROP_RATIO, 0.0, MAX_CROP_RATIO);
this.menuRightCrop.connect("value-changed", Lang.bind(this, this._onRightCropChanged));
this.menuRightCrop._streamEvents.connect("notify::value", Lang.bind(this, this._onRightCropChanged));
this.menuCrop.menu.addMenuItem(this.menuRightCrop);

this.menuBottomCrop = new PopupSliderMenuItem("Bottom", DEFAULT_CROP_RATIO, 0.0, MAX_CROP_RATIO);
this.menuBottomCrop.connect("value-changed", Lang.bind(this, this._onBottomCropChanged));
this.menuBottomCrop._streamEvents.connect("notify::value", Lang.bind(this, this._onBottomCropChanged));
this.menuCrop.menu.addMenuItem(this.menuBottomCrop);
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

Expand Down
5 changes: 3 additions & 2 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"3.24",
"3.26",
"3.28",
"3.30"
"3.30",
"3.36"
],
"url": "https://github.com/medenagan/window-corner-preview",
"uuid": "[email protected]",
"version": 3
"version": 4.1
}
16 changes: 13 additions & 3 deletions [email protected]/popupSliderMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const Bundle = Me.imports.bundle;
const normalizeRange = Bundle.normalizeRange;
const deNormalizeRange = Bundle.deNormalizeRange;

const Signals = imports.signals;

class EventSource {}
Signals.addSignalMethods(EventSource.prototype);


var PopupSliderMenuItem = new Lang.Class({
Name: "WindowCornerPreview.PopupSliderMenuItem",
Extends: PopupMenu.PopupBaseMenuItem,
Expand All @@ -30,6 +36,8 @@ var PopupSliderMenuItem = new Lang.Class({
params = params || {};

params.activate = false;

this._streamEvents = new EventSource();

this.parent(params);

Expand All @@ -44,12 +52,14 @@ var PopupSliderMenuItem = new Lang.Class({
this.value = this.defaultValue;

// PopupSliderMenuItem emits its own value-change event which provides a normalized value
this.slider.connect("value-changed", Lang.bind(this, function(x) {
this.slider.connect("notify::value", Lang.bind(this, function(x) {
let normalValue = this.value;
// Force the slider to set position on a stepped value (if necessary)
if (this.step !== undefined) this.value = normalValue;
// Don't through any event if step rounded it to the same value
if (normalValue !== this._lastValue) this.emit("value-changed", normalValue);
if (normalValue !== this._lastValue) {
this._streamEvents.emit("notify::value", normalValue);
}
this._lastValue = normalValue;
}));

Expand All @@ -65,6 +75,6 @@ var PopupSliderMenuItem = new Lang.Class({

set value(newValue) {
this._lastValue = normalizeRange(newValue, this.min, this.max, this.step);
this.slider.setValue(this._lastValue);
this.slider.value = this._lastValue;
}
});
21 changes: 14 additions & 7 deletions [email protected]/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,24 @@ var WindowCornerPreview = new Lang.Class({

if (! this._container) return;

this._container.foreach(function(actor) {
actor.destroy();
});

if (! this._window) return;
if (this.thumbnail) {
this._container.remove_actor(this.thumbnail);
this.thumbnail.destroy();
}

if (! this._window) {
return;
}

let mutw = this._window.get_compositor_private();

if (! mutw) return;
if (! mutw) {
return;
}

let windowTexture = mutw.get_texture();
let [windowWidth, windowHeight] = windowTexture.get_size();
let [windowWidth, windowHeight] = mutw.get_size();

/* To crop the window texture, for now I've found that:
1. Using a clip rect on Clutter.clone will hide the outside portion but also will KEEP the space along it
Expand Down Expand Up @@ -421,7 +427,7 @@ var WindowCornerPreview = new Lang.Class({
}

let thumbnail = new Clutter.Clone({ // list parameters https://www.roojs.org/seed/gir-1.2-gtk-3.0/seed/Clutter.Clone.html
source: windowTexture,
source: mutw,
reactive: false,

magnification_filter: Clutter.ScalingFilter.NEAREST, //NEAREST, //TRILINEAR,
Expand All @@ -443,6 +449,7 @@ var WindowCornerPreview = new Lang.Class({

});

this.thumbnail = thumbnail;
this._container.add_actor(thumbnail);

this._setPosition();
Expand Down