Skip to content

Commit 14c83ba

Browse files
committed
cinnamonEntry.js: Allow addContextMenu() to re-use an existing
PopupMenuManager. If the St.Entry is inside of a popup menu (and *not* a modal dialog), that menu's 'captured-event' handler can receive unintended events, and react to focus loss, closing both the original popup and context menu. The original menu's manager can safely deal with multiple popups, and ensure 'correct' behavior in this situation. ref: #13472
1 parent 2db8e83 commit 14c83ba

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

js/ui/cinnamonEntry.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,30 @@ function _onPopup(actor) {
139139
entry._menu.open();
140140
};
141141

142-
function addContextMenu(entry, params) {
142+
/**
143+
* addContextMenu:
144+
* @entry (St.Entry): the entry to add a context menu to
145+
* @params (object): optional parameters to pass to the _EntryMenu constructor.
146+
* Currently supports `isPassword` (boolean) to add a show/hide text toggle.
147+
* @parentMenu (PopupMenu.PopupMenu): optional parent menu. When the entry is
148+
* inside an existing popup menu (e.g. an applet menu), pass the parent menu
149+
* here so the context menu is registered as a child menu. This prevents the
150+
* parent menu from closing when the context menu is interacted with. When
151+
* omitted, a standalone PopupMenuManager is created for the context menu,
152+
* which is appropriate for entries in dialogs or other non-menu contexts.
153+
*/
154+
function addContextMenu(entry, params, parentMenu) {
143155
if (entry._menu)
144156
return;
145157

146158
entry._menu = new _EntryMenu(entry, params);
147-
entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry });
148-
entry._menuManager.addMenu(entry._menu);
159+
160+
if (parentMenu) {
161+
parentMenu.addChildMenu(entry._menu);
162+
} else {
163+
entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry });
164+
entry._menuManager.addMenu(entry._menu);
165+
}
149166

150167
// Add a click action to both the entry and its clutter_text; the former
151168
// so padding is included in the clickable area, the latter because the

0 commit comments

Comments
 (0)