我正在尝试禁用GNOME应用程序菜单(位于顶部面板中“活动”按钮右侧左侧的小工具),这样单击它就可以转到底层面板,这样即使单击此按钮,也可以将窗口从最大化状态拖动。有可能吗?
或者,一种更好的方法是将左键单击它传递给底层面板。我认为这也应该是可能的,但是我不熟悉API,也不熟悉我应该如何去做,尽管我更喜欢这个选项。
作为一个初学者,我尝试了设置Main.panel.statusArea.appMenu.container.enabled = false和类似的东西,但我猜不出真正的名字。如果能链接到这方面的文档就太好了。
在那之后,我想我可以枚举各种元素的所有成员,如下所示:
for(var propertyName in this._appMenu.container) {
log(propertyName);
}尽管如此,我仍然没有弄清楚这个属性是什么,或者我应该去哪里看。
我想将代码添加到扩展中,因此JavaScript代码是首选。
非常感谢。
发布于 2018-04-30 23:42:42
相关事件是我在本文档中找到的button-press-event和button-release-event:https://people.gnome.org/~gcampagna/docs/Clutter-1.0/Clutter.Actor.html和https://developer.gnome.org/clutter/stable/clutter-Events.html
一旦我使用以下命令订阅了它们:
this._wmHandlerIDs.push(Main.panel.statusArea.appMenu.actor.connect(
'button-press-event', Lang.bind(this, this._click)
));
this._wmHandlerIDs.push(Main.panel.statusArea.appMenu.actor.connect(
'button-release-event', Lang.bind(this, this._clicked)
));
Main._handledClick = 1; // ignore first click on the panel
Main._cancelClick = 0; // indicates if the button is still held然后我可以破解自己的方式,让应用程序按钮的行为像标题栏一样:
_click: function (actor, event) {
if (event.get_button() == 1) {
Main._cancelClick = 0;
if (event.get_click_count() == 1 && global.display.focus_window.get_maximized()) {
Mainloop.timeout_add(100, function () {
if (Main._handledClick == 1) {
Main._handledClick = 0;
} else {
if (Main._cancelClick == 0) {
/* disable the following mice temporarly so
that this hack works; a better way would be
nice; maybe that would also fix the mouse
button remaining stuck when dragging the
window */
Util.spawn(['xinput', '--disable', '12']);
Util.spawn(['xinput', '--disable', '15']);
Util.spawn(['xinput', '--disable', '16']);
Main.panel.statusArea.appMenu.hide();
Util.spawn(['xinput', '--enable', '12']);
Util.spawn(['xinput', '--enable', '15']);
Util.spawn(['xinput', '--enable', '16']);
Util.spawn(['xdotool', 'mousedown', '1']);
Mainloop.timeout_add(100, function () {
Main.panel.statusArea.appMenu.show();
});
}
}
});
}
} else if (event.get_button() == 2) {
global.display.focus_window.delete(global.get_current_time());
Mainloop.timeout_add(10, function () {
Util.spawn(['xdotool', 'key', 'Escape']);
});
}
},
_clicked: function (actor, event) {
if (event.get_button() == 1) {
Main._cancelClick = 1;
if (event.get_click_count() == 2) {
if (global.display.focus_window.get_maximized()) {
global.display.focus_window.unmaximize(MAXIMIZED);
} else {
global.display.focus_window.maximize(MAXIMIZED);
}
}
}
},我认为这些进口是必要的:
const Main = imports.ui.main;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const MAXIMIZED = Meta.MaximizeFlags.BOTH;也许它可以帮助某些人缩短他们在文档搜索中的艰苦努力。
https://stackoverflow.com/questions/50100546
复制相似问题