cleanup: Use inheritance for Actor classes instead of composition
Use GObject types when inheriting from native actor classes. Related to https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559 https://gitlab.gnome.org/GNOME/gnome-shell-extensions/merge_requests/89
This commit is contained in:
committed by
Florian Müllner
parent
a894897770
commit
63615cb657
@@ -923,11 +923,11 @@ const WindowList = GObject.registerClass({
|
||||
}
|
||||
|
||||
_updateKeyboardAnchor() {
|
||||
if (!Main.keyboard.actor)
|
||||
if (!Main.keyboard.keyboardActor)
|
||||
return;
|
||||
|
||||
let translationY = Main.overview.visible ? 0 : this.height;
|
||||
Main.keyboard.actor.translation_y = -translationY;
|
||||
Main.keyboard.keyboardActor.translation_y = -translationY;
|
||||
}
|
||||
|
||||
_onAppStateChanged(appSys, app) {
|
||||
|
||||
@@ -6,18 +6,18 @@ const Main = imports.ui.main;
|
||||
const Overview = imports.ui.overview;
|
||||
const { WorkspacesDisplay } = imports.ui.workspacesView;
|
||||
|
||||
let MyWorkspacesDisplay = class extends WorkspacesDisplay {
|
||||
constructor() {
|
||||
super();
|
||||
let MyWorkspacesDisplay = GObject.registerClass({
|
||||
GTypeName: 'WindowList_MyWorkspacesDisplay'
|
||||
}, class MyWorkspacesDisplay extends WorkspacesDisplay {
|
||||
_init() {
|
||||
super._init();
|
||||
|
||||
this.actor.add_constraint(
|
||||
this.add_constraint(
|
||||
new Layout.MonitorConstraint({
|
||||
primary: true,
|
||||
work_area: true,
|
||||
}));
|
||||
|
||||
this.actor.connect('destroy', this._onDestroy.bind(this));
|
||||
|
||||
this._workareasChangedId = global.display.connect('workareas-changed',
|
||||
this._onWorkAreasChanged.bind(this));
|
||||
this._onWorkAreasChanged();
|
||||
@@ -50,8 +50,8 @@ let MyWorkspacesDisplay = class extends WorkspacesDisplay {
|
||||
super._updateWorkspacesViews();
|
||||
|
||||
this._workspacesViews.forEach(v => {
|
||||
Main.layoutManager.overviewGroup.remove_actor(v.actor);
|
||||
Main.windowPicker.add_actor(v.actor);
|
||||
Main.layoutManager.overviewGroup.remove_actor(v);
|
||||
Main.windowPicker.add_actor(v);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,8 +59,10 @@ let MyWorkspacesDisplay = class extends WorkspacesDisplay {
|
||||
if (this._workareasChangedId)
|
||||
global.display.disconnect(this._workareasChangedId);
|
||||
this._workareasChangedId = 0;
|
||||
|
||||
super._onDestroy();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var WindowPicker = GObject.registerClass({
|
||||
GTypeName: 'WindowListWindowPicker',
|
||||
@@ -98,7 +100,7 @@ var WindowPicker = GObject.registerClass({
|
||||
Main.overview.addAction = a => this._backgroundGroup.add_action(a);
|
||||
|
||||
this._workspacesDisplay = new MyWorkspacesDisplay();
|
||||
this.add_child(this._workspacesDisplay.actor);
|
||||
this.add_child(this._workspacesDisplay);
|
||||
|
||||
Main.overview.addAction = addActionOrig;
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ const Main = imports.ui.main;
|
||||
const Workspace = imports.ui.workspace;
|
||||
const WorkspacesView = imports.ui.workspacesView;
|
||||
|
||||
var MyWindowOverlay = class extends Workspace.WindowOverlay {
|
||||
constructor(windowClone, parentActor) {
|
||||
super(windowClone, parentActor);
|
||||
var MyWindowOverlay = GObject.registerClass({
|
||||
GTypeName: 'WindowsNavigator_MyWindowOverlay'
|
||||
}, class MyWindowOverlay extends Workspace.WindowOverlay {
|
||||
_init(windowClone, parentActor) {
|
||||
super._init(windowClone, parentActor);
|
||||
|
||||
this._id = null;
|
||||
this._text = new St.Label({
|
||||
@@ -39,21 +41,23 @@ var MyWindowOverlay = class extends Workspace.WindowOverlay {
|
||||
this._text.set_position(Math.floor(textX) + 5, Math.floor(textY) + 5);
|
||||
this._text.raise_top();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var MyWorkspace = class extends Workspace.Workspace {
|
||||
constructor(metaWorkspace, monitorIndex) {
|
||||
super(metaWorkspace, monitorIndex);
|
||||
var MyWorkspace = GObject.registerClass({
|
||||
GTypeName: 'WindowsNavigator_MyWorkspace'
|
||||
}, class MyWorkspace extends Workspace.Workspace {
|
||||
_init(metaWorkspace, monitorIndex) {
|
||||
super._init(metaWorkspace, monitorIndex);
|
||||
|
||||
if (metaWorkspace && metaWorkspace.index() < 9) {
|
||||
this._tip = new St.Label({
|
||||
style_class: 'extension-windowsNavigator-window-tooltip',
|
||||
visible: false,
|
||||
});
|
||||
this.actor.add_actor(this._tip);
|
||||
this.add_actor(this._tip);
|
||||
|
||||
this.actor.connect('notify::scale-x', () => {
|
||||
this._tip.set_scale(1 / this.actor.scale_x, 1 / this.actor.scale_x);
|
||||
this.connect('notify::scale-x', () => {
|
||||
this._tip.set_scale(1 / this.scale_x, 1 / this.scale_x);
|
||||
});
|
||||
} else {
|
||||
this._tip = null;
|
||||
@@ -67,7 +71,7 @@ var MyWorkspace = class extends Workspace.Workspace {
|
||||
|
||||
// Hand code this instead of using _getSpacingAndPadding
|
||||
// because that fails on empty workspaces
|
||||
let node = this.actor.get_theme_node();
|
||||
let node = this.get_theme_node();
|
||||
let padding = {
|
||||
left: node.get_padding(St.Side.LEFT),
|
||||
top: node.get_padding(St.Side.TOP),
|
||||
@@ -111,11 +115,13 @@ var MyWorkspace = class extends Workspace.Workspace {
|
||||
this._windowOverlays[i].hideTooltip();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var MyWorkspacesView = class extends WorkspacesView.WorkspacesView {
|
||||
constructor(width, height, x, y, workspaces) {
|
||||
super(width, height, x, y, workspaces);
|
||||
var MyWorkspacesView = GObject.registerClass({
|
||||
GTypeName: 'WindowsNavigator_MyWorkspacesView'
|
||||
}, class MyWorkspacesView extends WorkspacesView.WorkspacesView {
|
||||
_init(width, height, x, y, workspaces) {
|
||||
super._init(width, height, x, y, workspaces);
|
||||
|
||||
this._pickWorkspace = false;
|
||||
this._pickWindow = false;
|
||||
@@ -238,7 +244,7 @@ var MyWorkspacesView = class extends WorkspacesView.WorkspacesView {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
class Extension {
|
||||
constructor() {
|
||||
|
||||
Reference in New Issue
Block a user