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