shellEntry: Don't use a ClutterClickAction to pop up a menu
This removes support for long press, but fixes the brokenness of other types of event handling. https://bugzilla.gnome.org/show_bug.cgi?id=683509
This commit is contained in:
parent
409af28cb7
commit
9dfd1bfa41
@ -126,34 +126,20 @@ function _setMenuAlignment(entry, stageX) {
|
|||||||
entry.menu.setSourceAlignment(entryX / entry.width);
|
entry.menu.setSourceAlignment(entryX / entry.width);
|
||||||
};
|
};
|
||||||
|
|
||||||
function _onClicked(action, actor) {
|
function _onButtonPressEvent(actor, event, entry) {
|
||||||
let entry = actor.menu ? actor : actor.get_parent();
|
|
||||||
|
|
||||||
if (entry.menu.isOpen) {
|
if (entry.menu.isOpen) {
|
||||||
entry.menu.close();
|
entry.menu.close();
|
||||||
} else if (action.get_button() == 3) {
|
return true;
|
||||||
let [stageX, stageY] = action.get_coords();
|
} else if (event.get_button() == 3) {
|
||||||
_setMenuAlignment(entry, stageX);
|
let [stageX, stageY] = event.get_coords();
|
||||||
entry.menu.open();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function _onLongPress(action, actor, state) {
|
|
||||||
let entry = actor.menu ? actor : actor.get_parent();
|
|
||||||
|
|
||||||
if (state == Clutter.LongPressState.QUERY)
|
|
||||||
return action.get_button() == 1 && !entry.menu.isOpen;
|
|
||||||
|
|
||||||
if (state == Clutter.LongPressState.ACTIVATE) {
|
|
||||||
let [stageX, stageY] = action.get_coords();
|
|
||||||
_setMenuAlignment(entry, stageX);
|
_setMenuAlignment(entry, stageX);
|
||||||
entry.menu.open();
|
entry.menu.open();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
function _onPopup(actor) {
|
function _onPopup(actor, entry) {
|
||||||
let entry = actor.menu ? actor : actor.get_parent();
|
|
||||||
let [success, textX, textY, lineHeight] = entry.clutter_text.position_to_coords(-1);
|
let [success, textX, textY, lineHeight] = entry.clutter_text.position_to_coords(-1);
|
||||||
if (success)
|
if (success)
|
||||||
entry.menu.setSourceAlignment(textX / entry.width);
|
entry.menu.setSourceAlignment(textX / entry.width);
|
||||||
@ -168,20 +154,11 @@ function addContextMenu(entry, params) {
|
|||||||
entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry });
|
entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry });
|
||||||
entry._menuManager.addMenu(entry.menu);
|
entry._menuManager.addMenu(entry.menu);
|
||||||
|
|
||||||
let clickAction;
|
// Add an event handler to both the entry and its clutter_text; the former
|
||||||
|
|
||||||
// Add a click action to both the entry and its clutter_text; the former
|
|
||||||
// so padding is included in the clickable area, the latter because the
|
// so padding is included in the clickable area, the latter because the
|
||||||
// event processing of ClutterText prevents event-bubbling.
|
// event processing of ClutterText prevents event-bubbling.
|
||||||
clickAction = new Clutter.ClickAction();
|
entry.clutter_text.connect('button-press-event', Lang.bind(null, _onButtonPressEvent, entry));
|
||||||
clickAction.connect('clicked', _onClicked);
|
entry.connect('button-press-event', Lang.bind(null, _onButtonPressEvent, entry));
|
||||||
clickAction.connect('long-press', _onLongPress);
|
|
||||||
entry.clutter_text.add_action(clickAction);
|
|
||||||
|
|
||||||
clickAction = new Clutter.ClickAction();
|
entry.connect('popup-menu', Lang.bind(null, _onPopup, entry));
|
||||||
clickAction.connect('clicked', _onClicked);
|
|
||||||
clickAction.connect('long-press', _onLongPress);
|
|
||||||
entry.add_action(clickAction);
|
|
||||||
|
|
||||||
entry.connect('popup-menu', _onPopup);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user