workspaceThumbnail: Consider porthole offsets

Since commit 9980c80619, the porthole position is ignored. As a result,
previews are only shown if the primary monitor is located at (0, 0).

To fix this, we either need to propagate the porthole to every thumbnail,
use a custom layout manager that applies an offset to all children, or
add an intermediate actor that offsets the contents.

The last option is the simplest and doesn't require calls into JS on
every allocation, so pick that one.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3781

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1721>
This commit is contained in:
Florian Müllner 2021-02-26 13:36:26 +01:00
parent c90bde464a
commit 49b7973177

View File

@ -271,8 +271,11 @@ var WorkspaceThumbnail = GObject.registerClass({
this._removed = false;
this._viewport = new Clutter.Actor();
this.add_child(this._viewport);
this._contents = new Clutter.Actor();
this.add_child(this._contents);
this._viewport.add_child(this._contents);
this.connect('destroy', this._onDestroy.bind(this));
@ -315,7 +318,8 @@ var WorkspaceThumbnail = GObject.registerClass({
}
setPorthole(x, y, width, height) {
this._contents.set_size(width, height);
this._viewport.set_size(width, height);
this._contents.set_position(-x, -y);
}
_lookupIndex(metaWindow) {
@ -598,7 +602,7 @@ var WorkspaceThumbnail = GObject.registerClass({
}
setScale(scaleX, scaleY) {
this._contents.set_scale(scaleX, scaleY);
this._viewport.set_scale(scaleX, scaleY);
}
});