我正在使用 GNOME Shell 43.9。
我的
extensions.js
看起来像:
const Me = ExtensionUtils.getCurrentExtension();
const windowFunctions = Me.imports.windowFunctions;
const markedWindowFunctions = Me.imports.markedWindowFunctions;
class Extension {
enable() {
....
}
function init(meta) {
log(`initializing ${meta.metadata.name}`);
return new Extension();
}
我的
windowFunctions.js
看起来像:
var WindowFunctions = class WindowFunctions {
_get_other_normal_windows_current_workspace_of_focused_window_wm_class = function () {
let win = Display.get_focus_window();
return this._get_normal_windows_current_workspace_given_wm_class(win.get_wm_class()).filter(w => win != w);
}
....
}
我的
markedWindowFunctions.js
目前看起来像:
var markedWindowFunctions = class markedWindowFunctions {
CloseOtherNotMarkedWindowsCurrentWorkspaceOfFocusedWindowWMClass() {
// call _get_other_normal_windows_current_workspace_of_focused_window_wm_class from here
}
}
如何从
_get_other_normal_windows_current_workspace_of_focused_window_wm_class
的WindowFunctions
呼叫CloseOtherNotMarkedWindowsCurrentWorkspaceOfFocusedWindowWMClass
的markedWindowFunctions
。
OP在这里。以下解决了我的问题。
const Me = imports.misc.extensionUtils.getCurrentExtension();
const { WindowFunctions } = Me.imports.windowFunctions;
var MarkedWindowFunctions = class MarkedWindowFunctions {
constructor() {
this.windowFunctionsInstance = new WindowFunctions();
}
CloseOtherNotMarkedWindowsCurrentWorkspaceOfFocusedWindowWMClass() {
// call let wins = this.windowFunctionsInstance._get_other_normal_windows_current_workspace_of_focused_window_wm_class from here
}
}