labwc: improve popups support (right click context menu working)

This commit is contained in:
Lemmy
2026-01-25 12:16:40 -05:00
parent 7610d306d3
commit 8d11b0be0a
26 changed files with 152 additions and 231 deletions
+3 -9
View File
@@ -173,10 +173,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
@@ -329,11 +327,7 @@ Item {
}
onClicked: mouse => {
if (mouse.button === Qt.RightButton) {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
}
}
+3 -9
View File
@@ -144,10 +144,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "cycle-visualizer") {
const types = ["linear", "mirrored", "wave"];
@@ -170,11 +168,7 @@ Item {
onClicked: mouse => {
if (mouse.button === Qt.RightButton) {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
} else {
const types = ["linear", "mirrored", "wave"];
const currentIndex = types.indexOf(currentVisualizerType);
+3 -9
View File
@@ -187,10 +187,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
@@ -249,11 +247,7 @@ Item {
}
onClicked: PanelService.getPanel("batteryPanel", screen)?.toggle(this)
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
}
}
+3 -9
View File
@@ -53,10 +53,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "toggle-bluetooth") {
BluetoothService.setBluetoothEnabled(!BluetoothService.enabled);
@@ -94,11 +92,7 @@ Item {
p.toggle(this);
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
tooltipText: {
if (pill.text !== "") {
+3 -9
View File
@@ -114,10 +114,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "open-display-settings") {
var settingsPanel = PanelService.getPanel("settingsPanel", screen);
@@ -169,11 +167,7 @@ Item {
onClicked: PanelService.getPanel("brightnessPanel", screen)?.toggle(this)
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
}
}
+4 -9
View File
@@ -136,10 +136,9 @@ Rectangle {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
// Close the context menu
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "open-calendar") {
PanelService.getPanel("clockPanel", screen)?.toggle(root);
@@ -177,11 +176,7 @@ Rectangle {
onClicked: mouse => {
TooltipService.hide();
if (mouse.button === Qt.RightButton) {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
} else {
PanelService.getPanel("clockPanel", screen)?.toggle(this);
}
+3 -9
View File
@@ -118,10 +118,8 @@ NIconButton {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "open-launcher") {
PanelService.getPanel("launcherPanel", screen)?.toggle();
@@ -145,11 +143,7 @@ NIconButton {
}
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
onMiddleClicked: PanelService.getPanel("launcherPanel", screen)?.toggle()
+3 -9
View File
@@ -57,10 +57,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
@@ -82,11 +80,7 @@ Item {
forceClose: root.showIcon && root.displayMode === "alwaysHide"
onClicked: CompositorService.cycleKeyboardLayout()
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
}
}
+3 -9
View File
@@ -60,10 +60,8 @@ NIconButton {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "launcher-settings") {
var panel = PanelService.getPanel("settingsPanel", screen);
@@ -78,10 +76,6 @@ NIconButton {
onClicked: PanelService.getPanel("launcherPanel", screen)?.toggle()
onMiddleClicked: PanelService.getPanel("launcherPanel", screen)?.toggle()
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
}
+3 -9
View File
@@ -67,10 +67,8 @@ Rectangle {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
@@ -83,11 +81,7 @@ Rectangle {
acceptedButtons: Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.RightButton) {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
}
}
+3 -8
View File
@@ -205,9 +205,8 @@ Item {
}
onTriggered: action => {
var popupWindow = PanelService.getPopupMenuWindow(screen);
if (popupWindow)
popupWindow.close();
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "play-pause")
MediaService.playPause();
@@ -377,11 +376,7 @@ Item {
PanelService.getPanel("mediaPlayerPanel", screen)?.toggle(container);
} else if (mouse.button === Qt.RightButton) {
TooltipService.hide();
var popupWindow = PanelService.getPopupMenuWindow(screen);
if (popupWindow) {
popupWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(container, screen);
}
PanelService.showContextMenu(contextMenu, container, screen);
} else if (mouse.button === Qt.MiddleButton && hasPlayer) {
MediaService.playPause();
TooltipService.hide();
+3 -9
View File
@@ -109,10 +109,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "toggle-mute") {
AudioService.setInputMuted(!AudioService.inputMuted);
@@ -164,11 +162,7 @@ Item {
PanelService.getPanel("audioPanel", screen)?.toggle(this);
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
onMiddleClicked: {
Quickshell.execDetached(["sh", "-lc", middleClickCommand]);
+3 -9
View File
@@ -53,10 +53,8 @@ Item {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "toggle-wifi") {
NetworkService.setWifiEnabled(!Settings.data.network.wifiEnabled);
@@ -115,11 +113,7 @@ Item {
panel?.toggle(this);
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
tooltipText: {
try {
+3 -9
View File
@@ -86,10 +86,8 @@ NIconButton {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "toggle-dnd") {
NotificationService.doNotDisturb = !NotificationService.doNotDisturb;
@@ -107,11 +105,7 @@ NIconButton {
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
Loader {
+3 -9
View File
@@ -72,10 +72,8 @@ NIconButton {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
@@ -85,10 +83,6 @@ NIconButton {
onClicked: PanelService.getPanel("sessionMenuPanel", screen)?.toggle()
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
}
+3 -9
View File
@@ -138,10 +138,8 @@ Rectangle {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
@@ -161,11 +159,7 @@ Rectangle {
TooltipService.hide();
} else if (mouse.button === Qt.RightButton) {
TooltipService.hide();
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
} else if (mouse.button === Qt.MiddleButton) {
TooltipService.hide();
openExternalMonitor();
+3 -29
View File
@@ -458,10 +458,8 @@ Rectangle {
return items;
}
onTriggered: (action, item) => {
var popupMenuWindow = PanelService.getPopupMenuWindow(root.screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(root.screen);
// Look up the window fresh each time to avoid stale references
const selectedWindow = root.getSelectedWindow();
@@ -964,30 +962,6 @@ Rectangle {
// Set the model directly
contextMenu.model = items;
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.open();
// Calculate menu position
const globalPos = item.mapToItem(root, 0, 0);
let menuX, menuY;
if (root.barPosition === "top") {
menuX = globalPos.x + (item.width / 2) - (contextMenu.implicitWidth / 2);
menuY = barHeight + Style.marginS;
} else if (root.barPosition === "bottom") {
const menuHeight = 12 + contextMenu.model.length * contextMenu.itemHeight;
menuX = globalPos.x + (item.width / 2) - (contextMenu.implicitWidth / 2);
menuY = -menuHeight - Style.marginS;
} else if (root.barPosition === "left") {
menuX = barHeight + Style.marginS;
menuY = globalPos.y + (item.height / 2) - (contextMenu.implicitHeight / 2);
} else {
// right
menuX = -contextMenu.implicitWidth - Style.marginS;
menuY = globalPos.y + (item.height / 2) - (contextMenu.implicitHeight / 2);
}
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, item, screen);
}
}
+3 -7
View File
@@ -419,9 +419,7 @@ Rectangle {
PanelService.openedPanel.close();
}
if (modelData.hasMenu && modelData.menu && popupMenuWindow && trayMenu && trayMenu.item) {
popupMenuWindow.open();
if (modelData.hasMenu && modelData.menu && trayMenu && trayMenu.item) {
// Position menu based on bar position
let menuX, menuY;
if (barPosition === "left") {
@@ -437,10 +435,8 @@ Rectangle {
menuX = (width / 2) - (trayMenu.item.width / 2);
menuY = (barPosition === "top") ? barHeight + Style.marginS - 2 : barHeight + Style.marginS - 2;
}
trayMenu.item.trayItem = modelData;
trayMenu.item.widgetSection = root.section;
trayMenu.item.widgetIndex = root.sectionWidgetIndex;
trayMenu.item.showAt(parent, menuX, menuY);
PanelService.showTrayMenu(root.screen, modelData, trayMenu.item, parent, menuX, menuY, root.section, root.sectionWidgetIndex);
} else {
Logger.d("Tray", "No menu available for", modelData.id, "or trayMenu not set");
}
+4 -9
View File
@@ -71,10 +71,9 @@ Item {
}
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (!action) {
return;
}
@@ -122,11 +121,7 @@ Item {
forceOpen: !isBarVertical && root.displayMode === "alwaysShow"
forceClose: isBarVertical || root.displayMode === "alwaysHide" || !pill.text
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
tooltipText: {
if (pill.text !== "") {
+3 -11
View File
@@ -91,11 +91,8 @@ Item {
]
onTriggered: action => {
// Close the popup menu window before handling the action
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "toggle-mute") {
AudioService.setOutputMuted(!AudioService.muted);
@@ -147,12 +144,7 @@ Item {
PanelService.getPanel("audioPanel", screen)?.toggle(this);
}
onRightClicked: {
// Get the shared popup menu window for this screen
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(pill, screen);
}
PanelService.showContextMenu(contextMenu, pill, screen);
}
onMiddleClicked: {
Quickshell.execDetached(["sh", "-lc", middleClickCommand]);
+3 -9
View File
@@ -38,10 +38,8 @@ NIconButton {
]
onTriggered: action => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
if (action === "random-wallpaper") {
WallpaperService.setRandomWallpaper();
@@ -58,10 +56,6 @@ NIconButton {
}
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(root, screen);
}
PanelService.showContextMenu(contextMenu, root, screen);
}
}
+4 -14
View File
@@ -424,10 +424,8 @@ Item {
}
onTriggered: (action, item) => {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.close();
}
contextMenu.close();
PanelService.closeContextMenu(screen);
const selectedWindow = root.getSelectedWindow();
@@ -469,11 +467,7 @@ Item {
acceptedButtons: Qt.RightButton
onClicked: mouse => {
if (mouse.button === Qt.RightButton) {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(workspaceBackground, screen);
}
PanelService.showContextMenu(contextMenu, workspaceBackground, screen);
}
}
}
@@ -1162,10 +1156,6 @@ Item {
}
function openGroupedContextMenu(item) {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(item, screen);
}
PanelService.showContextMenu(contextMenu, item, screen);
}
}
+5 -2
View File
@@ -2,6 +2,7 @@ import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Commons
import qs.Services.Compositor
import qs.Services.UI
import qs.Widgets
@@ -31,8 +32,10 @@ PanelWindow {
visible: false
color: "transparent"
// Use Top layer (same as MainScreen) for proper event handling
WlrLayershell.layer: WlrLayer.Top
// Use Top layer for proper event handling, but on labwc use Bottom
// to avoid stealing input from popups while still catching outside clicks.
// However, when a dialog is open, always use Top so dialogs appear above apps.
WlrLayershell.layer: (CompositorService.isLabwc && !hasDialog) ? WlrLayer.Bottom : WlrLayer.Top
WlrLayershell.keyboardFocus: hasDialog ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
WlrLayershell.namespace: "noctalia-" + windowType + "-" + (screen?.name || "unknown")
WlrLayershell.exclusionMode: ExclusionMode.Ignore
+2 -7
View File
@@ -239,9 +239,7 @@ SmartPanel {
return;
}
if (modelData.hasMenu && modelData.menu && panelContent.popupMenuWindow && panelContent.trayMenu && panelContent.trayMenu.item) {
panelContent.popupMenuWindow.open();
if (modelData.hasMenu && modelData.menu && panelContent.trayMenu && panelContent.trayMenu.item) {
const barPosition = Settings.getBarPositionForScreen(root.screen?.name);
let menuX, menuY;
@@ -256,10 +254,7 @@ SmartPanel {
menuY = trayIcon.height + Style.marginS;
}
panelContent.trayMenu.item.trayItem = modelData;
panelContent.trayMenu.item.widgetSection = root.widgetSection;
panelContent.trayMenu.item.widgetIndex = root.widgetIndex;
panelContent.trayMenu.item.showAt(trayIcon, menuX, menuY);
PanelService.showTrayMenu(root.screen, modelData, panelContent.trayMenu.item, trayIcon, menuX, menuY, root.widgetSection, root.widgetIndex);
}
}
}
+21
View File
@@ -270,6 +270,21 @@ Singleton {
}
}
// Helper to close any existing dialogs in a popup menu window
function closeExistingDialogs(popupMenuWindow) {
if (!popupMenuWindow || !popupMenuWindow.dialogParent)
return;
var dialogParent = popupMenuWindow.dialogParent;
for (var i = dialogParent.children.length - 1; i >= 0; i--) {
var child = dialogParent.children[i];
if (child && typeof child.close === "function") {
child.close();
}
}
popupMenuWindow.hasDialog = false;
}
// Open widget settings dialog for a bar widget
// Parameters:
// screen: The screen to show the dialog on
@@ -285,6 +300,9 @@ Singleton {
return;
}
// Close any existing dialogs first to prevent stacking
closeExistingDialogs(popupMenuWindow);
var component = Qt.createComponent(Quickshell.shellDir + "/Modules/Panels/Settings/Bar/BarWidgetSettingsDialog.qml");
function instantiateAndOpen() {
@@ -363,6 +381,9 @@ Singleton {
return;
}
// Close any existing dialogs first to prevent stacking
closeExistingDialogs(popupMenuWindow);
var component = Qt.createComponent(Quickshell.shellDir + "/Widgets/NPluginSettingsPopup.qml");
function instantiateAndOpen() {
+55
View File
@@ -63,6 +63,61 @@ Singleton {
return popupMenuWindows[screen.name] || null;
}
// Show a context menu with proper handling for all compositors
function showContextMenu(contextMenu, anchorItem, screen) {
if (!contextMenu || !anchorItem)
return;
// Close any previously opened context menu first
closeContextMenu(screen);
var popupMenuWindow = getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.showContextMenu(contextMenu);
contextMenu.openAtItem(anchorItem, screen);
}
}
// Close any open context menu or popup menu window
function closeContextMenu(screen) {
var popupMenuWindow = getPopupMenuWindow(screen);
if (popupMenuWindow && popupMenuWindow.visible) {
popupMenuWindow.close();
}
}
// Show a tray menu with proper handling for all compositors
// Returns true if menu was shown successfully
function showTrayMenu(screen, trayItem, trayMenu, anchorItem, menuX, menuY, widgetSection, widgetIndex) {
if (!trayItem || !trayMenu || !anchorItem)
return false;
// Close any previously opened menu first
closeContextMenu(screen);
trayMenu.trayItem = trayItem;
trayMenu.widgetSection = widgetSection;
trayMenu.widgetIndex = widgetIndex;
var popupMenuWindow = getPopupMenuWindow(screen);
if (popupMenuWindow) {
popupMenuWindow.open();
trayMenu.showAt(anchorItem, menuX, menuY);
} else {
return false;
}
return true;
}
// Close tray menu
function closeTrayMenu(screen) {
var popupMenuWindow = getPopupMenuWindow(screen);
if (popupMenuWindow) {
// This closes both the window and calls hideMenu on the tray menu
popupMenuWindow.close();
}
}
// Returns a panel (loads it on-demand if not yet loaded)
function getPanel(name, screen) {
if (!screen) {