appDisplay: Simplify AppDisplay
Inherit St.Widget and remove the custom layout manager. Instead, override vfunc_allocate(). Also remove the view stack. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/880
This commit is contained in:
parent
548e19a7cd
commit
b57bcf823f
@ -952,38 +952,17 @@ var AllView = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var ViewStackLayout = GObject.registerClass({
|
|
||||||
Signals: { 'allocated-size-changed': { param_types: [GObject.TYPE_INT,
|
|
||||||
GObject.TYPE_INT] } },
|
|
||||||
}, class ViewStackLayout extends Clutter.BinLayout {
|
|
||||||
vfunc_allocate(actor, box) {
|
|
||||||
let availWidth = box.x2 - box.x1;
|
|
||||||
let availHeight = box.y2 - box.y1;
|
|
||||||
// Prepare children of all views for the upcoming allocation, calculate all
|
|
||||||
// the needed values to adapt available size
|
|
||||||
this.emit('allocated-size-changed', availWidth, availHeight);
|
|
||||||
super.vfunc_allocate(actor, box);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var AppDisplay = GObject.registerClass(
|
var AppDisplay = GObject.registerClass(
|
||||||
class AppDisplay extends St.BoxLayout {
|
class AppDisplay extends St.Widget {
|
||||||
_init() {
|
_init() {
|
||||||
super._init({
|
super._init({
|
||||||
style_class: 'app-display',
|
style_class: 'app-display',
|
||||||
vertical: true,
|
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
y_expand: true,
|
y_expand: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._view = new AllView();
|
this._view = new AllView();
|
||||||
this._viewStackLayout = new ViewStackLayout();
|
this.add_actor(this._view);
|
||||||
this._viewStack = new St.Widget({ x_expand: true, y_expand: true,
|
|
||||||
layout_manager: this._viewStackLayout });
|
|
||||||
this._viewStackLayout.connect('allocated-size-changed', this._onAllocatedSizeChanged.bind(this));
|
|
||||||
this.add_actor(this._viewStack);
|
|
||||||
|
|
||||||
this._viewStack.add_actor(this._view);
|
|
||||||
|
|
||||||
this._switcherooNotifyId = global.connect('notify::switcheroo-control',
|
this._switcherooNotifyId = global.connect('notify::switcheroo-control',
|
||||||
() => this._updateDiscreteGpuAvailable());
|
() => this._updateDiscreteGpuAvailable());
|
||||||
@ -1008,15 +987,13 @@ class AppDisplay extends St.BoxLayout {
|
|||||||
this._view.selectApp(id);
|
this._view.selectApp(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onAllocatedSizeChanged(actor, width, height) {
|
vfunc_allocate(box, flags) {
|
||||||
let box = new Clutter.ActorBox();
|
box = this.get_theme_node().get_content_box(box);
|
||||||
box.x1 = box.y1 = 0;
|
let availWidth = box.get_width();
|
||||||
box.x2 = width;
|
let availHeight = box.get_height();
|
||||||
box.y2 = height;
|
|
||||||
box = this._viewStack.get_theme_node().get_content_box(box);
|
|
||||||
let availWidth = box.x2 - box.x1;
|
|
||||||
let availHeight = box.y2 - box.y1;
|
|
||||||
this._view.adaptToSize(availWidth, availHeight);
|
this._view.adaptToSize(availWidth, availHeight);
|
||||||
|
|
||||||
|
this._view.allocate(box, flags);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user