diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:07:22 +0000 |
commit | f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7 (patch) | |
tree | ce9e8db2d4e8799780fa72ae8f1953039373e2ee /js/ui/backgroundMenu.js | |
parent | Initial commit. (diff) | |
download | gnome-shell-f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7.tar.xz gnome-shell-f9d480cfe50ca1d7a0f0b5a2b8bb9932962bfbe7.zip |
Adding upstream version 3.38.6.upstream/3.38.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/ui/backgroundMenu.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/js/ui/backgroundMenu.js b/js/ui/backgroundMenu.js new file mode 100644 index 0000000..e31e4c1 --- /dev/null +++ b/js/ui/backgroundMenu.js @@ -0,0 +1,69 @@ +// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- +/* exported addBackgroundMenu */ + +const { Clutter, St } = imports.gi; + +const BoxPointer = imports.ui.boxpointer; +const Main = imports.ui.main; +const PopupMenu = imports.ui.popupMenu; + +var BackgroundMenu = class BackgroundMenu extends PopupMenu.PopupMenu { + constructor(layoutManager) { + super(layoutManager.dummyCursor, 0, St.Side.TOP); + + this.addSettingsAction(_("Change Background…"), 'gnome-background-panel.desktop'); + this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); + this.addSettingsAction(_("Display Settings"), 'gnome-display-panel.desktop'); + this.addSettingsAction(_("Settings"), 'gnome-control-center.desktop'); + + this.actor.add_style_class_name('background-menu'); + + layoutManager.uiGroup.add_actor(this.actor); + this.actor.hide(); + } +}; + +function addBackgroundMenu(actor, layoutManager) { + actor.reactive = true; + actor._backgroundMenu = new BackgroundMenu(layoutManager); + actor._backgroundManager = new PopupMenu.PopupMenuManager(actor); + actor._backgroundManager.addMenu(actor._backgroundMenu); + + function openMenu(x, y) { + Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0); + actor._backgroundMenu.open(BoxPointer.PopupAnimation.FULL); + } + + let clickAction = new Clutter.ClickAction(); + clickAction.connect('long-press', (action, theActor, state) => { + if (state == Clutter.LongPressState.QUERY) { + return (action.get_button() == 0 || + action.get_button() == 1) && + !actor._backgroundMenu.isOpen; + } + if (state == Clutter.LongPressState.ACTIVATE) { + let [x, y] = action.get_coords(); + openMenu(x, y); + actor._backgroundManager.ignoreRelease(); + } + return true; + }); + clickAction.connect('clicked', action => { + if (action.get_button() == 3) { + let [x, y] = action.get_coords(); + openMenu(x, y); + } + }); + actor.add_action(clickAction); + + let grabOpBeginId = global.display.connect('grab-op-begin', () => { + clickAction.release(); + }); + + actor.connect('destroy', () => { + actor._backgroundMenu.destroy(); + actor._backgroundMenu = null; + actor._backgroundManager = null; + global.display.disconnect(grabOpBeginId); + }); +} |