summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2014-05-31 05:19:20 +0200
committerFlorian Müllner <fmuellner@gnome.org>2014-06-02 23:48:53 +0200
commite51eb723fc7a7dbd7d79bbfd74f72e016d05aa66 (patch)
tree76b9f674afd4d2af63b948679b0cb63b05ef617f
parent5b61f2d64263bd987a9b55a806b0b8be1a148eb2 (diff)
windowMenu: Do a better job with faking the source actor
The 0x0 dummyCursor works well when the menu pops up directly underneath the pointer (e.g. when triggered by right-clicking the titlebar) or by keyboard, but not when triggered by the menu button - the menu does not point to the center of the button's bottom edge, and unless the user keeps holding the mouse button while moving into the menu, the menu will be dismissed immediately on button release. Address these issues by using the button geometry to overlay the window button with an appropriately sized actor that acts as a proper sourceActor, to make the window menu behavior consistent with other shell menus. https://bugzilla.gnome.org/show_bug.cgi?id=731058
-rw-r--r--js/ui/windowMenu.js31
1 files changed, 22 insertions, 9 deletions
diff --git a/js/ui/windowMenu.js b/js/ui/windowMenu.js
index f993e15a..cec044e0 100644
--- a/js/ui/windowMenu.js
+++ b/js/ui/windowMenu.js
@@ -15,8 +15,8 @@ const WindowMenu = new Lang.Class({
Name: 'WindowMenu',
Extends: PopupMenu.PopupMenu,
- _init: function(window) {
- this.parent(Main.layoutManager.dummyCursor, 0, St.Side.TOP);
+ _init: function(window, sourceActor) {
+ this.parent(sourceActor, 0, St.Side.TOP);
this.actor.add_style_class_name('window-menu');
@@ -129,10 +129,10 @@ const AppMenu = new Lang.Class({
Name: 'AppMenu',
Extends: RemoteMenu.RemoteMenu,
- _init: function(window) {
+ _init: function(window, sourceActor) {
let app = Shell.WindowTracker.get_default().get_window_app(window);
- this.parent(Main.layoutManager.dummyCursor, app.menu, app.action_group);
+ this.parent(sourceActor, app.menu, app.action_group);
this.actor.add_style_class_name('fallback-app-menu');
let variant = window.get_gtk_theme_variant();
@@ -149,11 +149,18 @@ const WindowMenuManager = new Lang.Class({
_init: function() {
this._manager = new PopupMenu.PopupMenuManager({ actor: Main.layoutManager.dummyCursor });
+
+ this._sourceActor = new St.Widget({ reactive: true, visible: false });
+ this._sourceActor.connect('button-press-event', Lang.bind(this,
+ function() {
+ this._manager.activeMenu.toggle();
+ }));
+ Main.uiGroup.add_actor(this._sourceActor);
},
showWindowMenuForWindow: function(window, type, rect) {
- let menu = (type == Meta.WindowMenuType.WM) ? new WindowMenu(window)
- : new AppMenu(window);
+ let menuType = (type == Meta.WindowMenuType.WM) ? WindowMenu : AppMenu;
+ let menu = new menuType(window, this._sourceActor);
this._manager.addMenu(menu);
@@ -161,12 +168,18 @@ const WindowMenuManager = new Lang.Class({
window.check_alive(global.get_current_time());
});
- Main.layoutManager.setDummyCursorGeometry(rect.x, rect.y, 0, 0);
+ this._sourceActor.set_size(rect.width, rect.height);
+ this._sourceActor.set_position(rect.x, rect.y);
+ this._sourceActor.show();
+
menu.open(BoxPointer.PopupAnimation.NONE);
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
menu.connect('open-state-changed', Lang.bind(this, function(menu_, isOpen) {
- if (!isOpen)
- menu.destroy();
+ if (isOpen)
+ return;
+
+ this._sourceActor.hide();
+ menu.destroy();
}));
}
});