Соответствующими событиями являются 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;
Может быть, это поможет кому-то сократить трудную борьбу в поисках документации.