From 110b37ba24c653228c44a4ce3f2d9b7e543f2305 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 15:59:30 -0800 Subject: [PATCH 01/13] panel.js: Remove the TextShadower object This isn't used anywhere in Cinnamon or any Xlets. --- js/ui/panel.js | 83 -------------------------------------------------- 1 file changed, 83 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index a2628a7ed6..1024c18044 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1205,89 +1205,6 @@ AnimatedIcon.prototype = { Mainloop.source_remove(this._timeoutId); } }; -/* FIXME: Find out if this TextShadower functionality below is actually used */ - -function TextShadower() { - this._init(); -} - -TextShadower.prototype = { - _init: function() { - - this.actor = new Cinnamon.GenericContainer(); - - this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); - this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); - this.actor.connect('allocate', Lang.bind(this, this._allocate)); - - this._label = new St.Label(); - this.actor.add_actor(this._label); - for (let i = 0; i < 4; i++) { - let actor = new St.Label({ style_class: 'label-shadow' }); - actor.clutter_text.ellipsize = Pango.EllipsizeMode.END; - this.actor.add_actor(actor); - } - this._label.raise_top(); - }, - - _getPreferredWidth: function(actor, forHeight, alloc) { - let [minWidth, natWidth] = this._label.get_preferred_width(forHeight); - alloc.min_size = minWidth + 2; - alloc.natural_size = natWidth + 2; - }, - - _getPreferredHeight: function(actor, forWidth, alloc) { - let [minHeight, natHeight] = this._label.get_preferred_height(forWidth); - alloc.min_size = minHeight + 2; - alloc.natural_size = natHeight + 2; - }, - - _allocate: function(actor, box, flags) { - let children = this.actor.get_children(); - - let availWidth = box.x2 - box.x1; - let availHeight = box.y2 - box.y1; - - let [minChildWidth, minChildHeight, natChildWidth, natChildHeight] = - this._label.get_preferred_size(); - - let childWidth = Math.min(natChildWidth, availWidth - 2); - let childHeight = Math.min(natChildHeight, availHeight - 2); - - for (let i = 0; i < children.length; i++) { - let child = children[i]; - let childBox = new Clutter.ActorBox(); - // The order of the labels here is arbitrary, except - // we know the "real" label is at the end because Clutter.Group - // sorts by Z order - switch (i) { - case 0: // top - childBox.x1 = 1; - childBox.y1 = 0; - break; - case 1: // right - childBox.x1 = 2; - childBox.y1 = 1; - break; - case 2: // bottom - childBox.x1 = 1; - childBox.y1 = 2; - break; - case 3: // left - childBox.x1 = 0; - childBox.y1 = 1; - break; - case 4: // center - childBox.x1 = 1; - childBox.y1 = 1; - break; - } - childBox.x2 = childBox.x1 + childWidth; - childBox.y2 = childBox.y1 + childHeight; - child.allocate(childBox, flags); - } - } -}; function SettingsLauncher(label, keyword, icon) { this._init(label, keyword, icon); From 821442cccbe79ed754c0fc95a489e19026094f3e Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 18:06:54 -0800 Subject: [PATCH 02/13] panel.js: Port the PanelManager to GObject Clean up uses of Lang.bind() and clean up a few variable names and some code styling --- js/ui/panel.js | 226 ++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 114 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 1024c18044..fb59317921 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -9,6 +9,7 @@ */ const Cairo = imports.cairo; const Clutter = imports.gi.Clutter; +const GObject = imports.gi.GObject; const Lang = imports.lang; const Mainloop = imports.mainloop; const Meta = imports.gi.Meta; @@ -325,108 +326,110 @@ function updatePanelsMeta(meta, panel_props) { * #PanelManager creates panels and startup and * provides methods for easier access of panels */ -function PanelManager() { - this._init(); -} +var PanelManager = GObject.registerClass({ + Signals: { + 'monitors-changed': {}, + }, +}, class PanelManager extends GObject.Object { + _init() { + super._init(); -PanelManager.prototype = { - _init: function() { this.dummyPanels = []; this.panelCount = 0; this.panels = []; this.panelsMeta = []; // Properties of panels in format [, ] - this.canAdd = true; // Whether there is space for more panels to be added + this.canAddPanel = true; this.monitorCount = global.display.get_n_monitors(); + // don't start up in edit mode, can loop with empty vertical panels let editMode = global.settings.get_boolean("panel-edit-mode"); if (editMode == true) - global.settings.set_boolean("panel-edit-mode", false); // don't start up in edit mode, can loop with empty vertical panels + global.settings.set_boolean("panel-edit-mode", false); this._fullPanelLoad(); - this._setMainPanel(); this.addPanelMode = false; - this.handling_panels_changed = false; + this.handlingPanelsChanged = false; - this._panelsEnabledId = global.settings.connect("changed::panels-enabled", Lang.bind(this, this._onPanelsEnabledChanged)); - this._panelEditModeId = global.settings.connect("changed::panel-edit-mode", Lang.bind(this, this._onPanelEditModeChanged)); - this._monitorsChangedId = Main.layoutManager.connect("monitors-changed", Lang.bind(this, this._onMonitorsChanged)); + global.settings.connect("changed::panels-enabled", this._onPanelsEnabledChanged.bind(this)); + global.settings.connect("changed::panel-edit-mode", this._onPanelEditModeChanged.bind(this)); + Main.layoutManager.connect("monitors-changed", this._onMonitorsChanged.bind(this)); - this._addOsd = new ModalDialog.InfoOSD(_("Select position of new panel. Esc to cancel.")); + this._addOsd = new ModalDialog.InfoOSD(_("Select position of new panel. Esc to cancel.")); this._moveOsd = new ModalDialog.InfoOSD(_("Select new position of panel. Esc to cancel.")); this._addOsd.hide(); this._moveOsd.hide(); - this._checkCanAdd(); + this._checkCanAddPanel(); this._updateAllPointerBarriers(); - }, + } /** * #_fullPanelLoad * * @short_description: Does a full load of all panels * - * #_fullPanelLoad loads all panels in order, and makes any adjustments to permit vertical panels to fit snugly - * between horizontal ones + * #_fullPanelLoad loads all panels in order, and makes any adjustments to permit + * vertical panels to fit snugly between horizontal ones */ - _fullPanelLoad : function () { + _fullPanelLoad() { let monitor = 0; let stash = []; // panel id, monitor, panel type let monitorCount = global.display.get_n_monitors(); - let panel_defs = getPanelsEnabledList(); + let panelDefs = getPanelsEnabledList(); // // First pass through just to count the monitors, as there is no ordering to rely on // - let good_defs = []; + let goodDefs = []; let removals = []; - for (let i = 0, len = panel_defs.length; i < len; i++) { - let elements = panel_defs[i].split(":"); + for (let i = 0, len = panelDefs.length; i < len; i++) { + let elements = panelDefs[i].split(":"); if (elements.length != 3) { - global.log("Invalid panel definition: " + panel_defs[i]); + global.log("Invalid panel definition: " + panelDefs[i]); removals.push(i); continue; } if (elements[PanelDefElement.MONITOR] >= monitorCount) { // Ignore, but don't remove. Less monitors can be a temporary condition. - global.log("Ignoring panel definition for nonexistent monitor: " + panel_defs[i]); + global.log("Ignoring panel definition for nonexistent monitor: " + panelDefs[i]); continue; } // Some sanitizing - if (good_defs.find((good_def) => { - const good_elements = good_def.split(":"); + if (goodDefs.find((goodDef) => { + const goodElements = goodDef.split(":"); // Ignore any duplicate IDs - if (good_elements[PanelDefElement.ID] === elements[PanelDefElement.ID]) { - global.log("Duplicate ID detected in panel definition: " + panel_defs[i]); + if (goodElements[PanelDefElement.ID] === elements[PanelDefElement.ID]) { + global.log("Duplicate ID detected in panel definition: " + panelDefs[i]); return true; } // Ignore any duplicate monitor/position combinations - if ((good_elements[PanelDefElement.MONITOR] === elements[PanelDefElement.MONITOR]) && (good_elements[PanelDefElement.POSITION] === elements[PanelDefElement.POSITION])) { - global.log("Duplicate monitor+position detected in panel definition: " + panel_defs[i]); + if ((goodElements[PanelDefElement.MONITOR] === elements[PanelDefElement.MONITOR]) && (goodElements[PanelDefElement.POSITION] === elements[PanelDefElement.POSITION])) { + global.log("Duplicate monitor+position detected in panel definition: " + panelDefs[i]); return true; } return false; })) { - removals.push(panel_defs[i]); + removals.push(panelDefs[i]); continue; } - good_defs.push(panel_defs[i]); + goodDefs.push(panelDefs[i]); } if (removals.length > 0) { - let clean_defs = panel_defs.filter((def) => !removals.includes(def)); + let cleanDefs = panelDefs.filter((def) => !removals.includes(def)); global.log("Removing invalid panel definitions: " + removals); - setPanelsEnabledList(clean_defs); + setPanelsEnabledList(cleanDefs); } // set up the list of panels - for (let i = 0, len = good_defs.length; i < len; i++) { - let elements = good_defs[i].split(":"); + for (let i = 0, len = goodDefs.length; i < len; i++) { + let elements = goodDefs[i].split(":"); let jj = getPanelLocFromName(elements[PanelDefElement.POSITION]); // panel orientation @@ -481,31 +484,31 @@ PanelManager.prototype = { if (this.panels[i].panelPosition == PanelLoc.left || this.panels[i].panelPosition == PanelLoc.right) this.panels[i]._moveResizePanel(); } - }, + } /** * disablePanels: * * Disables (hide and lock) all panels */ - disablePanels: function() { + disablePanels() { for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i]) this.panels[i].disable(); } - }, + } /** * enablePanels: * * Enables all panels */ - enablePanels: function() { + enablePanels() { for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i]) this.panels[i].enable(); } - }, + } /** * setPanelsOpacity: @@ -513,12 +516,12 @@ PanelManager.prototype = { * * Sets the opacity of all panels to @opacity */ - setPanelsOpacity: function(opacity) { + setPanelsOpacity(opacity) { for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i]) this.panels[i].actor.opacity = opacity; } - }, + } /** * lowerActorBelowPanels: @@ -526,7 +529,7 @@ PanelManager.prototype = { * * Lowers actor to just under the panel actors */ - lowerActorBelowPanels: function(actor, group) { + lowerActorBelowPanels(actor, group) { for (let i = 0, len = this.panels.length; i < len; i++) { if (!this.panels[i]) continue; @@ -544,7 +547,7 @@ PanelManager.prototype = { } else break; } - }, + } /** * removePanel: @@ -552,7 +555,7 @@ PanelManager.prototype = { * * Remove the panel from the list panels-enabled */ - removePanel: function(panelId) { + removePanel(panelId) { this.panelCount -= 1; let list = getPanelsEnabledList(); for (let i = 0, len = list.length; i < len; i++) { @@ -563,7 +566,7 @@ PanelManager.prototype = { } setPanelsEnabledList(list); - }, + } /** * addPanel: @@ -572,7 +575,7 @@ PanelManager.prototype = { * * Adds a new panel to the specified position */ - addPanel: function(monitorIndex, panelPosition) { + addPanel(monitorIndex, panelPosition) { let list = getPanelsEnabledList(); let i = 0; // Start counting at 1 for compatibility @@ -609,14 +612,14 @@ PanelManager.prototype = { list.push(i + ":" + monitorIndex + ":" + "right"); break; default: - global.log("addPanel - unrecognised panel position "+panelPosition); + global.log("addPanel - unrecognised panel position " + panelPosition); } setPanelsEnabledList(list); // Delete all panel dummies if (this.addPanelMode) this._destroyDummyPanels(); - }, + } /** * movePanel: @@ -625,7 +628,7 @@ PanelManager.prototype = { * * Moves the panel of id this.moveId to the specified position */ - movePanel: function(monitorIndex, panelPosition) { + movePanel(monitorIndex, panelPosition) { let list = getPanelsEnabledList(); let i = -1; @@ -657,14 +660,14 @@ PanelManager.prototype = { // Delete all panel dummies if (this.addPanelMode) this._destroyDummyPanels(); - }, + } /** * _destroyDummyPanels: * * Destroys all panel dummies */ - _destroyDummyPanels: function() { + _destroyDummyPanels() { for (let i = 0, len = this.dummyPanels.length; i < len; i++) { let removedDummyPanelIndexes = []; for (let j = 0, len = this.dummyPanels[i].length; j < len; j++) { @@ -682,7 +685,7 @@ PanelManager.prototype = { this._addOsd.hide(); this._moveOsd.hide(); Main.keybindingManager.removeHotKey('close-add-panel'); - }, + } /** * getPanelsInMonitor: @@ -692,14 +695,14 @@ PanelManager.prototype = { * * Returns: an array of panels */ - getPanelsInMonitor: function(monitorIndex) { + getPanelsInMonitor(monitorIndex) { let returnValue = []; for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i] && this.panels[i].monitorIndex == monitorIndex) returnValue.push(this.panels[i]); } return returnValue; - }, + } /** * getPanels: @@ -709,9 +712,9 @@ PanelManager.prototype = { * Returns: an array of panels */ - getPanels: function() { + getPanels() { return this.panels; - }, + } /** * getPanel: @@ -722,7 +725,7 @@ PanelManager.prototype = { * * Returns: the panel required (null if panel not found) */ - getPanel: function(monitorIndex, panelPosition) { + getPanel(monitorIndex, panelPosition) { for (let i = 0, len = this.panels.length; i < len; i++) { if (!this.panels[i]) continue; @@ -730,7 +733,7 @@ PanelManager.prototype = { return this.panels[i]; } return null; - }, + } /** * updatePanelsVisibility: @@ -739,13 +742,13 @@ PanelManager.prototype = { * by WindowManager after window map/tile/etc animations, and after popup * menus close. */ - updatePanelsVisibility: function() { + updatePanelsVisibility() { for (let i = 0, len = this.panels.length; i < len; i++) { if (!this.panels[i]) continue; this.panels[i]._updatePanelVisibility(); } - }, + } /** * _loadPanel: @@ -760,7 +763,7 @@ PanelManager.prototype = { * * Returns (Panel.Panel): Panel created */ - _loadPanel: function(ID, monitorIndex, panelPosition, panelList, metaList) { + _loadPanel(ID, monitorIndex, panelPosition, panelList, metaList) { if (!panelList) panelList = this.panels; if (!metaList) metaList = this.panelsMeta; @@ -814,21 +817,20 @@ PanelManager.prototype = { this.panelCount += 1; return panelList[ID]; - }, - - _checkCanAdd: function() { - let panelCount = (this.monitorCount * 4) - this.panelCount; // max of 4 panels on a monitor, one per edge + } - this.canAdd = panelCount > 0; - }, + _checkCanAddPanel() { + let panelCount = (this.monitorCount * 4) - this.panelCount; + this.canAddPanel = panelCount > 0; + } - _updateAllPointerBarriers: function() { + _updateAllPointerBarriers() { for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i]) { this.panels[i]._updatePanelBarriers(); } } - }, + } /** * _onPanelsEnabledChanged: @@ -836,10 +838,10 @@ PanelManager.prototype = { * This will be called whenever the panels-enabled settings key is changed * i.e. when panels are added, moved or removed. */ - _onPanelsEnabledChanged: function() { - if (this.handling_panels_changed) + _onPanelsEnabledChanged() { + if (this.handlingPanelsChanged) return; - this.handling_panels_changed = true; + this.handlingPanelsChanged = true; let newPanels = new Array(this.panels.length); let newMeta = new Array(this.panels.length); @@ -854,30 +856,28 @@ PanelManager.prototype = { continue; } - let ID = parseInt(elements[0]); // each panel is stored as ID:monitor:panelposition - let mon = parseInt(elements[1]); + // each panel is stored as ID:monitor:panelposition + let ID = parseInt(elements[0]); + let mon = parseInt(elements[1]); let ploc = getPanelLocFromName(elements[2]); if (this.panels[ID]) { // If (existing) panel is moved - newMeta[ID] = [mon, ploc]; //Note: meta [i][0] is the monitor meta [i][1] is the panelposition newPanels[ID] = this.panels[ID]; // Move panel object to newPanels this.panels[ID] = null; // avoids triggering the destroy logic that follows delete this.panels[ID]; - if (newMeta[ID][0] != this.panelsMeta[ID][0] // monitor changed - || + if (newMeta[ID][0] != this.panelsMeta[ID][0] || // monitor changed newMeta[ID][1] != this.panelsMeta[ID][1]) { // or panel position changed - newPanels[ID].updatePosition(newMeta[ID][0], newMeta[ID][1]); - AppletManager.updateAppletsOnPanel(newPanels[ID]); // Asymmetrical applets such as panel launchers, systray etc. - // need reorienting within the applet using their - // on_orientation_changed function + // Asymmetrical applets such as panel launchers, systray etc. + // need reorienting within the applet using their + // on_orientation_changed function + AppletManager.updateAppletsOnPanel(newPanels[ID]); } - } else { // new panel - + } else { // new panel let panel = this._loadPanel(ID, mon, ploc, @@ -915,21 +915,21 @@ PanelManager.prototype = { } this._setMainPanel(); - this._checkCanAdd(); + this._checkCanAddPanel(); this._updateAllPointerBarriers(); // If the user removed the last panel, pop up a dialog to ask if they want to open panel settings if (panelProperties.length == 0) { let lastPanelRemovedDialog = new ModalDialog.ConfirmDialog( _("You don't have any panels added.\nDo you want to open panel settings?"), - Lang.bind(this, function() { Util.spawnCommandLine("cinnamon-settings panel"); })); + () => { Util.spawnCommandLine("cinnamon-settings panel"); }); lastPanelRemovedDialog.open(); } - this.handling_panels_changed = false; - }, + this.handlingPanelsChanged = false; + } - _onMonitorsChanged: function() { + _onMonitorsChanged() { const oldCount = this.monitorCount; this.monitorCount = global.display.get_n_monitors(); @@ -976,29 +976,29 @@ PanelManager.prototype = { } this._setMainPanel(); - this._checkCanAdd(); + this._checkCanAddPanel(); this._updateAllPointerBarriers(); - }, + } - _onPanelEditModeChanged: function() { + _onPanelEditModeChanged() { if (!global.settings.get_boolean("panel-edit-mode")) { if (this.addPanelMode) this._destroyDummyPanels(); } - }, + } /** * addPanelQuery: * * Prompts user where to add the panel */ - addPanelQuery: function() { - if (this.addPanelMode || !this.canAdd) + addPanelQuery() { + if (this.addPanelMode || !this.canAddPanel) return; - this._showDummyPanels(Lang.bind(this, this.addPanel)); + this._showDummyPanels(this.addPanel.bind(this)); this._addOsd.show(); - }, + } /** * movePanelQuery: @@ -1006,14 +1006,14 @@ PanelManager.prototype = { * * Prompts user where to move the panel */ - movePanelQuery: function(id) { - if (this.addPanelMode || !this.canAdd) + movePanelQuery(id) { + if (this.addPanelMode || !this.canAddPanel) return; this.moveId = id; - this._showDummyPanels(Lang.bind(this, this.movePanel)); + this._showDummyPanels(this.movePanel.bind(this)); this._moveOsd.show(); - }, + } /** * _showDummyPanels: @@ -1021,7 +1021,7 @@ PanelManager.prototype = { * * shows the dummy panels */ - _showDummyPanels: function(callback) { + _showDummyPanels(callback) { this.dummyCallback = callback; this.dummyPanels = []; @@ -1046,25 +1046,25 @@ PanelManager.prototype = { } this.addPanelMode = true; - Main.keybindingManager.addHotKey('close-add-panel', 'Escape', Lang.bind(this, function() { + Main.keybindingManager.addHotKey('close-add-panel', 'Escape', () => { if (this.addPanelMode) this._destroyDummyPanels(); - })); + }); return true; - }, + } // Set Main.panel so that applets that look for it don't break - _setMainPanel: function() { + _setMainPanel() { for (let i = 0; i < this.panels.length; i++) { if (this.panels[i]) { Main.panel = this.panels[i]; break; } } - }, + } - resetPanelDND: function() { + resetPanelDND() { for (let i = 0; i < this.panels.length; i++) { if (this.panels[i]) { this.panels[i].resetDNDZones(); @@ -1072,9 +1072,7 @@ PanelManager.prototype = { } } -}; // end of panel manager -Signals.addSignalMethods(PanelManager.prototype); - +}); /** * #PanelDummy @@ -1351,8 +1349,8 @@ PanelContextMenu.prototype = { open: function(animate) { PopupMenu.PopupMenu.prototype.open.call(this, animate); - this.movePanelItem.setSensitive(Main.panelManager.canAdd); - this.addPanelItem.setSensitive(Main.panelManager.canAdd); + this.movePanelItem.setSensitive(Main.panelManager.canAddPanel); + this.addPanelItem.setSensitive(Main.panelManager.canAddPanel); // this.pasteAppletItem.setSensitive(AppletManager.clipboard.length != 0); let {definitions} = AppletManager; From 87640fdb12d7c249ecea9084f12398df2caee64a Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 19:36:43 -0800 Subject: [PATCH 03/13] panel.js: Port the PanelDummy to GObject This removes a use of CinnamonGenericContainer --- js/ui/panel.js | 79 ++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index fb59317921..b283a8272f 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1081,24 +1081,26 @@ var PanelManager = GObject.registerClass({ * #PanelDummy creates some boxes at possible panel locations for users to * select where to place their new panels */ -function PanelDummy(monitorIndex, panelPosition, callback) { - this._init(monitorIndex, panelPosition, callback); -} +var PanelDummy = GObject.registerClass( +class PanelDummy extends St.Widget { + _init(monitorIndex, panelPosition, callback) { + super._init({ + style_class: 'panel-dummy', + reactive: true, + track_hover: true, + important: true, + }); -PanelDummy.prototype = { - _init: function(monitorIndex, panelPosition, callback) { this.monitorIndex = monitorIndex; this.panelPosition = panelPosition; this.callback = callback; this.monitor = global.display.get_monitor_geometry(monitorIndex); - let defaultheight = 40 * global.ui_scale; + const defaultheight = 40 * global.ui_scale; - this.actor = new Cinnamon.GenericContainer({style_class: "panel-dummy", reactive: true, track_hover: true, important: true}); + Main.layoutManager.addChrome(this, { addToWindowgroup: false }); - Main.layoutManager.addChrome(this.actor, { addToWindowgroup: false }); - // - // layouts set to be full width horizontal panels, and vertical panels set to use as much available space as is left - // + // layouts set to be full width horizontal panels, + // and vertical panels set to use as much available space as is left let tpanelHeight = 0; let bpanelHeight = 0; @@ -1111,55 +1113,56 @@ PanelDummy.prototype = { switch (panelPosition) { case PanelLoc.top: - this.actor.set_size(this.monitor.width, defaultheight); - this.actor.set_position(this.monitor.x, this.monitor.y); + this.set_size(this.monitor.width, defaultheight); + this.set_position(this.monitor.x, this.monitor.y); break; case PanelLoc.bottom: - this.actor.set_size(this.monitor.width, defaultheight); - this.actor.set_position(this.monitor.x, this.monitor.y + this.monitor.height - defaultheight); + this.set_size(this.monitor.width, defaultheight); + this.set_position(this.monitor.x, this.monitor.y + this.monitor.height - defaultheight); break; case PanelLoc.left: - this.actor.set_size( defaultheight,this.monitor.height - tpanelHeight - bpanelHeight); - this.actor.set_position(this.monitor.x, this.monitor.y + tpanelHeight); + this.set_size( defaultheight,this.monitor.height - tpanelHeight - bpanelHeight); + this.set_position(this.monitor.x, this.monitor.y + tpanelHeight); break; case PanelLoc.right: - this.actor.set_size( defaultheight,this.monitor.height - tpanelHeight - bpanelHeight); - this.actor.set_position(this.monitor.x + this.monitor.width - defaultheight, this.monitor.y + tpanelHeight); + this.set_size( defaultheight,this.monitor.height - tpanelHeight - bpanelHeight); + this.set_position(this.monitor.x + this.monitor.width - defaultheight, this.monitor.y + tpanelHeight); break; default: - global.log("paneDummy - unrecognised panel position "+panelPosition); + global.log("paneDummy - unrecognised panel position " + panelPosition); } + } - this.actor.connect('button-press-event', Lang.bind(this, this._onClicked)); - this.actor.connect('enter-event', Lang.bind(this, this._onEnter)); - this.actor.connect('leave-event', Lang.bind(this, this._onLeave)); - }, - - _onClicked: function() { + vfunc_button_press_event(event) { this.callback(this.monitorIndex, this.panelPosition); - }, + return Clutter.EVENT_STOP; + } - _onEnter: function() { - this.actor.add_style_pseudo_class('entered'); + vfunc_enter_event(event) { + this.add_style_pseudo_class('entered'); if (this.noStyle) - this.actor.opacity = 160; - }, + this.opacity = 160; + return Clutter.EVENT_STOP; + } - _onLeave: function() { - this.actor.remove_style_pseudo_class('entered'); + vfunc_leave_event(event) { + this.remove_style_pseudo_class('entered'); if (this.noStyle) - this.actor.opacity = 100; - }, + this.opacity = 100; + return Clutter.EVENT_STOP; + } /** * destroy: * * Destroys panel dummy actor */ - destroy: function() { - Main.layoutManager.removeChrome(this.actor); + destroy() { + Main.layoutManager.removeChrome(this); + + super.destroy(); } -} +}); function AnimatedIcon(name, size) { this._init(name, size); From 0c7320d10210872eed3cc07800414cbed024e290 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 19:51:12 -0800 Subject: [PATCH 04/13] panel.js: Remove the AnimatedIcon object We only have one unmaintained applet using this currently. For the use case of a spinner, we can add a dedicated object for that purpose. We have other uses for that. --- js/ui/panel.js | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index b283a8272f..0899f62152 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1164,49 +1164,6 @@ class PanelDummy extends St.Widget { } }); -function AnimatedIcon(name, size) { - this._init(name, size); -} - -AnimatedIcon.prototype = { - _init: function(name, size) { - this.actor = new St.Bin({ visible: false }); - this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); - this.actor.connect('notify::visible', Lang.bind(this, function() { - if (this.actor.visible) { - this._timeoutId = Mainloop.timeout_add(ANIMATED_ICON_UPDATE_TIMEOUT, Lang.bind(this, this._update)); - } else { - if (this._timeoutId) - Mainloop.source_remove(this._timeoutId); - this._timeoutId = 0; - } - })); - - this._timeoutId = 0; - this._i = 0; - this._animations = St.TextureCache.get_default().load_sliced_image (global.datadir + '/theme/' + name, size, size, null); - this.actor.set_child(this._animations); - }, - - _update: function() { - this._animations.hide_all(); - this._animations.show(); - if (this._i && this._i < this._animations.get_n_children()) - this._animations.get_child_at_index(this._i++).show(); - else { - this._i = 1; - if (this._animations.get_n_children()) - this._animations.get_child_at_index(0).show(); - } - return true; - }, - - _onDestroy: function() { - if (this._timeoutId) - Mainloop.source_remove(this._timeoutId); - } -}; - function SettingsLauncher(label, keyword, icon) { this._init(label, keyword, icon); } From 8ab903e04a82b7547e86c985369da9a244d87174 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 20:10:42 -0800 Subject: [PATCH 05/13] panel.js: Port the SettingsLauncher object to a class Remove usage of Lang.bind() as well --- js/ui/panel.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 0899f62152..6a5473066b 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1164,22 +1164,16 @@ class PanelDummy extends St.Widget { } }); -function SettingsLauncher(label, keyword, icon) { - this._init(label, keyword, icon); -} - -SettingsLauncher.prototype = { - __proto__: PopupMenu.PopupIconMenuItem.prototype, - - _init: function (label, keyword, icon) { - PopupMenu.PopupIconMenuItem.prototype._init.call(this, label, icon, St.IconType.SYMBOLIC); +var SettingsLauncher = class SettingsLauncher extends PopupMenu.PopupIconMenuItem { + _init (label, keyword, icon) { + super._init.call(this, label, icon, St.IconType.SYMBOLIC); this._keyword = keyword; - this.connect('activate', Lang.bind(this, function() { + this.connect('activate', () => { Util.spawnCommandLine("cinnamon-settings " + this._keyword); - })); - }, -}; + }); + } +} function PanelContextMenu(launcher, orientation, panelId) { this._init(launcher, orientation, panelId); From c86f487c25d9da6ead216faf1a27b0482fe704d0 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 20:32:15 -0800 Subject: [PATCH 06/13] panel.js: Port the PanelContextMenu to class Remove old commented out options. These have been disabled for a long time. They can be re-added if we want to bring them back. --- js/ui/panel.js | 107 ++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 73 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 6a5473066b..65e4916d41 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1175,118 +1175,82 @@ var SettingsLauncher = class SettingsLauncher extends PopupMenu.PopupIconMenuIte } } -function PanelContextMenu(launcher, orientation, panelId) { - this._init(launcher, orientation, panelId); -} - -PanelContextMenu.prototype = { - __proto__: PopupMenu.PopupMenu.prototype, +var PanelContextMenu = class PanelContextMenu extends PopupMenu.PopupMenu { + _init(launcher, orientation, panelId) { + super._init.call(this, launcher.actor, orientation); - _init: function(launcher, orientation, panelId) { - PopupMenu.PopupMenu.prototype._init.call(this, launcher.actor, orientation); Main.uiGroup.add_actor(this.actor); this.actor.hide(); this.panelId = panelId; - let moreSettingsMenuItem = new SettingsLauncher(_("Panel settings"), "panel --panel " + panelId, "xsi-cog"); + const moreSettingsMenuItem = new SettingsLauncher( + _("Panel settings"), "panel --panel " + panelId, "xsi-cog"); this.addMenuItem(moreSettingsMenuItem); - let applet_settings_item = new SettingsLauncher(_("Applets"), "applets --panel " + panelId, "xsi-addon"); + const applet_settings_item = new SettingsLauncher( + _("Applets"), "applets --panel " + panelId, "xsi-addon"); this.addMenuItem(applet_settings_item); let menu = this; - menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line + menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // Panel Edit mode let editMode = global.settings.get_boolean("panel-edit-mode"); let panelEditMode = new PopupMenu.PopupSwitchMenuItem(_("Panel edit mode"), editMode); - panelEditMode.connect('toggled', function(item) { + panelEditMode.connect('toggled', (item) => { global.settings.set_boolean("panel-edit-mode", item.state); }); - menu.addMenuItem(panelEditMode); // menu item for panel edit mode - this.panel_edit_setting_id = global.settings.connect('changed::panel-edit-mode', function() { + menu.addMenuItem(panelEditMode); + this._panelEditSettingId = global.settings.connect('changed::panel-edit-mode', () => { panelEditMode.setToggleState(global.settings.get_boolean("panel-edit-mode")); }); - this.connect("destroy", Lang.bind(this, function() { - global.settings.disconnect(this.panel_edit_setting_id); - this.panel_edit_setting_id = 0; - })) + this.connect("destroy", () => { + global.settings.disconnect(this._panelEditSettingId); + this._panelEditSettingId = 0; + }); - menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line + menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - menu.movePanelItem = new PopupMenu.PopupIconMenuItem(_("Move"), "xsi-move", St.IconType.SYMBOLIC); // submenu item move panel - menu.movePanelItem.activate = Lang.bind(menu, function() { + menu.movePanelItem = new PopupMenu.PopupIconMenuItem(_("Move"), "xsi-move", St.IconType.SYMBOLIC); + menu.movePanelItem.activate = () => { Main.panelManager.movePanelQuery(this.panelId); this.close(true); - }); + }; menu.addMenuItem(menu.movePanelItem); let menuItem = new PopupMenu.PopupIconMenuItem(_("Remove"), "xsi-list-remove", St.IconType.SYMBOLIC); // submenu item remove panel - menuItem.activate = Lang.bind(menu, function() { + menuItem.activate = () => { let confirm = new ModalDialog.ConfirmDialog(_("Are you sure you want to remove this panel?"), - function() { + () => { Main.panelManager.removePanel(panelId); }); confirm.open(); - }); + }; menu.addMenuItem(menuItem); menu.addPanelItem = new PopupMenu.PopupIconMenuItem(_("Add a new panel"), "xsi-list-add", St.IconType.SYMBOLIC); // submenu item add panel - menu.addPanelItem.activate = Lang.bind(menu, function() { + menu.addPanelItem.activate = () => { Main.panelManager.addPanelQuery(); this.close(true); - }); + }; menu.addMenuItem(menu.addPanelItem); - // menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line - - - // menu.copyAppletItem = new PopupMenu.PopupIconMenuItem(_("Copy applets"), "xsi-edit-copy", St.IconType.SYMBOLIC); - // menu.copyAppletItem.activate = Lang.bind(menu, function() { - // AppletManager.copyAppletConfiguration(this.panelId); - // this.close(true); - // }); - // menu.addMenuItem(menu.copyAppletItem); // submenu item copy applet config - - // menu.pasteAppletItem = new PopupMenu.PopupIconMenuItem(_("Paste applets"), "xsi-edit-paste", St.IconType.SYMBOLIC); - // menu.pasteAppletItem.activate = Lang.bind(menu, function() { - // let dialog = new ModalDialog.ConfirmDialog( - // _("Pasting applet configuration will remove all existing applets on this panel. Do you want to continue?") + "\n\n", - // Lang.bind(this, function() { - // AppletManager.pasteAppletConfiguration(this.panelId); - // })); - // dialog.open(); - // }); - // menu.addMenuItem(menu.pasteAppletItem); // submenu item paste applet config - - // menu.clearAppletItem = new PopupMenu.PopupIconMenuItem(_("Clear all applets"), "xsi-edit-clear-all", St.IconType.SYMBOLIC); - // menu.clearAppletItem.activate = Lang.bind(menu, function() { - // let dialog = new ModalDialog.ConfirmDialog( - // _("Are you sure you want to clear all applets on this panel?") + "\n\n", - // Lang.bind(this, function() { - // AppletManager.clearAppletConfiguration(this.panelId); - // })); - // dialog.open(); - // }); - - // menu.addMenuItem(menu.clearAppletItem); // submenu item clear all applets - - menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line + menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); menu.troubleshootItem = new PopupMenu.PopupSubMenuMenuItem(_("Troubleshoot")); - menu.troubleshootItem.menu.addAction(_("Restart Cinnamon"), function(event) { + menu.troubleshootItem.menu.addAction(_("Restart Cinnamon"), (event) => { Main.restartCinnamon(true); }); - menu.troubleshootItem.menu.addAction(_("Looking Glass"), function(event) { + menu.troubleshootItem.menu.addAction(_("Looking Glass"), (event) => { Main.createLookingGlass().open(); }); - menu.troubleshootItem.menu.addAction(_("Restore all settings to default"), function(event) { + menu.troubleshootItem.menu.addAction(_("Restore all settings to default"), (event) => { let confirm = new ModalDialog.ConfirmDialog(_("Are you sure you want to restore all settings to default?\n\n"), - function() { + () => { Util.spawnCommandLine("gsettings reset-recursively org.cinnamon"); Util.spawnCommandLine("gsettings reset-recursively org.cinnamon.desktop.input-sources"); Main.restartCinnamon(true); @@ -1294,18 +1258,17 @@ PanelContextMenu.prototype = { confirm.open(); }); - menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); // separator line + menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); menu.addMenuItem(menu.troubleshootItem); this.addMenuItem(new SettingsLauncher(_("System Settings"), "", "xsi-preferences")); - }, + } - open: function(animate) { - PopupMenu.PopupMenu.prototype.open.call(this, animate); + open(animate) { + super.open.call(this, animate); this.movePanelItem.setSensitive(Main.panelManager.canAddPanel); this.addPanelItem.setSensitive(Main.panelManager.canAddPanel); - // this.pasteAppletItem.setSensitive(AppletManager.clipboard.length != 0); let {definitions} = AppletManager; let nonEmpty = false; @@ -1315,10 +1278,8 @@ PanelContextMenu.prototype = { break; } } - //this.copyAppletItem.setSensitive(nonEmpty); - //this.clearAppletItem.setSensitive(nonEmpty); } -} +}; function PanelZoneDNDHandler(panelZone, zoneString, panelId){ this._init(panelZone, zoneString, panelId); From 37ada06edb08d51668ebdc6cc3e1b5c2f62ed2e7 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Fri, 20 Feb 2026 22:50:45 -0800 Subject: [PATCH 07/13] panel.js: Port the PanelZoneDNDHandler to class --- js/ui/panel.js | 85 +++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 65e4916d41..6639400f5d 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1281,12 +1281,8 @@ var PanelContextMenu = class PanelContextMenu extends PopupMenu.PopupMenu { } }; -function PanelZoneDNDHandler(panelZone, zoneString, panelId){ - this._init(panelZone, zoneString, panelId); -} - -PanelZoneDNDHandler.prototype = { - _init : function(panelZone, zoneString, panelId) { +var PanelZoneDNDHandler = class { + constructor(panelZone, zoneString, panelId) { this._panelZone = panelZone; this._panelZone._delegate = this; this._zoneString = zoneString; @@ -1297,16 +1293,15 @@ PanelZoneDNDHandler.prototype = { this._origAppletCenters = null; this._origAppletPos = -1; - this._panelZone.connect('leave-event', Lang.bind(this, this._handleLeaveEvent)); - }, - - handleDragOver: function(source, actor, x, y, time) { + this._panelZone.connect('leave-event', this._handleLeaveEvent.bind(this)); + } - if (!(source instanceof Applet.Applet)) return DND.DragMotionResult.NO_DROP; + handleDragOver(source, actor, x, y, time) { + if (!(source instanceof Applet.Applet)) + return DND.DragMotionResult.NO_DROP; - if (!this._hasSupportedLayout(source)) { + if (!this._hasSupportedLayout(source)) return DND.DragMotionResult.NO_DROP; - } let vertical_panel = this._panelZone.get_parent()._delegate.is_vertical; let children = this._panelZone.get_children(); @@ -1321,18 +1316,16 @@ PanelZoneDNDHandler.prototype = { for (j = 0; j < children.length; j++) { let allocation = children[j].get_allocation_box(); let center = 0; - if (vertical_panel) { + if (vertical_panel) center = (allocation.y1 + allocation.y2) / 2; - } else { + else center = (allocation.x1 + allocation.x2) / 2; - } this._origAppletCenters.push(center); } - if(horizontal_rtl) { + if(horizontal_rtl) this._origAppletCenters.reverse(); - } } let dragPos = vertical_panel ? y : x; @@ -1342,11 +1335,10 @@ PanelZoneDNDHandler.prototype = { i++; } - if(horizontal_rtl) { + if(horizontal_rtl) pos = this._origAppletCenters.length - i; - } else { + else pos = i; - } if (pos != this._dragPlaceholderPos) { this._dragPlaceholderPos = pos; @@ -1383,28 +1375,28 @@ PanelZoneDNDHandler.prototype = { } return DND.DragMotionResult.MOVE_DROP; - }, + } - _handleLeaveEvent: function() { + _handleLeaveEvent() { this._clearDragPlaceholder(); - }, + } - handleDragOut: function() { + handleDragOut() { this._clearDragPlaceholder(); - }, + } - acceptDrop: function(source, actor, x, y, time) { + acceptDrop(source, actor, x, y, time) { this._origAppletCenters = null; - if (!(source instanceof Applet.Applet)) return false; + if (!(source instanceof Applet.Applet)) + return false; // We want to ensure that applets placed in a panel can be shown correctly // If the applet is of type Icon Applet then should be fine // otherwise we look to see if it has declared itself suitable if (source instanceof Applet.TextIconApplet || !(source instanceof Applet.IconApplet)) { - if (!this._hasSupportedLayout(source)) { + if (!this._hasSupportedLayout(source)) return false; - } } let children = this._panelZone.get_children(); @@ -1417,10 +1409,10 @@ PanelZoneDNDHandler.prototype = { } = source.actor._applet; for (let i = 0, len = children.length; i < len; i++) { - if (children[i]._delegate instanceof Applet.Applet){ + if (children[i]._delegate instanceof Applet.Applet) { children[i]._applet._newOrder = curAppletPos; curAppletPos++; - } else if (children[i] == this._dragPlaceholder.actor){ + } else if (children[i] == this._dragPlaceholder.actor) { insertAppletPos = curAppletPos; curAppletPos++; } @@ -1431,7 +1423,8 @@ PanelZoneDNDHandler.prototype = { && sourceAppletLocation === this._zoneString && insertAppletPos === -1 ); - if (!isSameLocation) source.actor._applet._newOrder = insertAppletPos === -1 ? 0 : insertAppletPos; + if (!isSameLocation) + source.actor._applet._newOrder = insertAppletPos === -1 ? 0 : insertAppletPos; source.actor._applet._newPanelLocation = this._panelZone; source.actor._applet._zoneString = this._zoneString; source.actor._applet._newPanelId = this._panelId; @@ -1467,30 +1460,36 @@ PanelZoneDNDHandler.prototype = { } return true; - }, + } - _clearDragPlaceholder: function() { + _clearDragPlaceholder() { if (this._dragPlaceholder) { this._dragPlaceholder.animateOutAndDestroy(); this._dragPlaceholder = null; this._dragPlaceholderPos = -1; } - }, + } - _hasSupportedLayout: function(applet) { + _hasSupportedLayout(applet) { let layout = applet.getAllowedLayout(); - if (layout == Applet.AllowedLayout.BOTH) return true; - if (applet instanceof Applet.IconApplet && !(applet instanceof Applet.TextIconApplet)) return true; - if (layout == ((this._panelZone.get_parent()._delegate.is_vertical) ? Applet.AllowedLayout.VERTICAL : Applet.AllowedLayout.HORIZONTAL)) return true; + if (layout == Applet.AllowedLayout.BOTH) + return true; + + if (applet instanceof Applet.IconApplet && !(applet instanceof Applet.TextIconApplet)) + return true; + + if (layout == ((this._panelZone.get_parent()._delegate.is_vertical) ? Applet.AllowedLayout.VERTICAL : Applet.AllowedLayout.HORIZONTAL)) + return true; + return false; - }, + } - reset: function() { + reset() { this._origAppletCenters = null; this._origAppletPos = -1; this._clearDragPlaceholder(); } -} +}; /** * #Panel: From 373f45e0fb98c74a1a799b6abfc409e4bb7bb031 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Sat, 21 Feb 2026 14:02:47 -0800 Subject: [PATCH 08/13] panel.js: Port the Panel object to class --- js/ui/panel.js | 209 +++++++++++++++++++++++++------------------------ 1 file changed, 105 insertions(+), 104 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 6639400f5d..7f61da3994 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1514,12 +1514,13 @@ var PanelZoneDNDHandler = class { * * This represents a panel on the screen. */ -function Panel(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { - this._init(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight); -} +// function Panel(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { +// this._init(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight); +// } -Panel.prototype = { - _init : function(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { +// Panel.prototype = { +var Panel = class { + constructor(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { this.panelId = id; this.monitorIndex = monitorIndex; @@ -1605,7 +1606,7 @@ Panel.prototype = { this._signalManager.connect(global.settings, "changed::no-adjacent-panel-barriers", this._updatePanelBarriers, this); this._onPanelZoneSizesChanged(); - }, + } /** * updatePosition: @@ -1614,7 +1615,7 @@ Panel.prototype = { * * Moves the panel to the monitor @monitorIndex and position @panelPosition */ - updatePosition: function(monitorIndex, panelPosition) { + updatePosition(monitorIndex, panelPosition) { this.monitorIndex = monitorIndex this.panelPosition = panelPosition; this._positionChanged = true; @@ -1626,7 +1627,7 @@ Panel.prototype = { this.addContextMenuToPanel(panelPosition); this.addPanelStyleClass(panelPosition); this._moveResizePanel(); - }, + } /** * addContextMenuToPanel: @@ -1634,7 +1635,7 @@ Panel.prototype = { * * Adds a context menu to the panel */ - addContextMenuToPanel: function(panelPosition) { + addContextMenuToPanel(panelPosition) { switch (panelPosition) { case PanelLoc.top: @@ -1655,7 +1656,7 @@ Panel.prototype = { this._menus.addMenu(this._context_menu); return; - }, + } /** * addPanelStyleClass: @@ -1663,7 +1664,7 @@ Panel.prototype = { * * Adds the panel style class. NB the original #panel style class is kept */ - addPanelStyleClass: function(panelPosition) { + addPanelStyleClass(panelPosition) { switch (panelPosition) { case PanelLoc.top: @@ -1694,7 +1695,7 @@ Panel.prototype = { global.log("addPanelStyleClass - unrecognised panel position "+panelPosition); } return; - }, + } /** * destroy: @@ -1702,7 +1703,7 @@ Panel.prototype = { * * Destroys the panel */ - destroy: function(removeIconSizes = true) { + destroy(removeIconSizes = true) { if (this._destroyed) return; this._destroyed = true; // set this early so that any routines triggered during // the destroy process can test it @@ -1729,9 +1730,9 @@ Panel.prototype = { this.monitor = null; return; - }, + } - peekPanel: function() { + peekPanel() { if (!this._hidden || this._peeking) return; @@ -1748,7 +1749,7 @@ Panel.prototype = { this._updatePanelVisibility(); return false; }); - }, + } /** * highlight: @@ -1756,7 +1757,7 @@ Panel.prototype = { * * Turns on/off the highlight of the panel */ - highlight: function(highlight) { + highlight(highlight) { if (highlight == this.actor.has_style_pseudo_class('highlight')) return; @@ -1764,16 +1765,16 @@ Panel.prototype = { this._highlighted = highlight; this._updatePanelVisibility(); - }, + } /** * isHideable: * * Returns: whether the panel can be hidden (auto-hide or intellihide) */ - isHideable: function() { + isHideable() { return this._autohideSettings != "false"; - }, + } /** * _getProperty @@ -1784,7 +1785,7 @@ Panel.prototype = { * * Returns: property required */ - _getProperty: function(key, type){ + _getProperty(key, type){ let values = global.settings.get_strv(key); let property; for (let i = 0; i < values.length; i++){ @@ -1806,7 +1807,7 @@ Panel.prototype = { default: return property; } - }, + } /** * _getJSONProperty @@ -1816,7 +1817,7 @@ Panel.prototype = { * * Returns: property required */ - _getJSONProperty: function(key){ + _getJSONProperty(key){ let json = global.settings.get_string(key); Util.tryFn(function() { @@ -1828,9 +1829,9 @@ Panel.prototype = { }); return json; - }, + } - handleDragOver: function(source, actor, x, y, time) { + handleDragOver(source, actor, x, y, time) { // // For empty panels. If over left,right,center box then will not get here. // @@ -1855,13 +1856,13 @@ Panel.prototype = { this._dragShowId = Mainloop.timeout_add(500, leaveIfOut); return DND.DragMotionResult.NO_DROP; - }, + } /** * _updatePanelBarriers: * * https://cgit.freedesktop.org/cgit/?url=xorg/proto/fixesproto/plain/fixesproto.txt */ - _updatePanelBarriers: function() { + _updatePanelBarriers() { this._clearPanelBarriers(); @@ -1964,9 +1965,9 @@ Panel.prototype = { } else { // actor without width or height this._clearPanelBarriers(); } - }, + } - _clearPanelBarriers: function() { + _clearPanelBarriers() { if (this._leftPanelBarrier) this._leftPanelBarrier.destroy(); if (this._rightPanelBarrier) @@ -1980,9 +1981,9 @@ Panel.prototype = { this._rightPanelBarrier = null; this._topPanelBarrier = null; this._bottomPanelBarrier = null; - }, + } - _onPanelEditModeChanged: function() { + _onPanelEditModeChanged() { let old_mode = this._panelEditMode; this._panelEditMode = global.settings.get_boolean("panel-edit-mode"); @@ -2027,9 +2028,9 @@ Panel.prototype = { } this.actor.queue_relayout(); - }, + } - _onButtonPressEvent: function (actor, event) { + _onButtonPressEvent(actor, event) { if (event.get_button() == 1) { if (this._context_menu.isOpen) this._context_menu.toggle(); @@ -2062,9 +2063,9 @@ Panel.prototype = { } } return; - }, + } - _onFocusChanged: function() { + _onFocusChanged() { if (global.display.focus_window && this._focusWindow !== undefined && this._focusWindow == global.display.focus_window) return; @@ -2079,9 +2080,9 @@ Panel.prototype = { this._signalManager.connect(this._focusWindow, "position-changed", this._updatePanelVisibility, this); this._signalManager.connect(this._focusWindow, "size-changed", this._updatePanelVisibility, this); this._updatePanelVisibility(); - }, + } - _processPanelAutoHide: function() { + _processPanelAutoHide() { this._autohideSettings = this._getProperty(PANEL_AUTOHIDE_KEY, "s"); if (this._autohideSettings == "intel") { @@ -2102,7 +2103,7 @@ Panel.prototype = { this._updatePanelVisibility(); Main.layoutManager._chrome.modifyActorParams(this.actor, { affectsStruts: this._autohideSettings == "false" }); - }, + } /** * _getScaledPanelHeight: * @@ -2110,11 +2111,11 @@ Panel.prototype = { * * returns : panelheight */ - _getScaledPanelHeight: function() { + _getScaledPanelHeight() { let panelHeight = 0; panelHeight = this._getProperty(PANEL_HEIGHT_KEY, "i") * global.ui_scale; return panelHeight < 20 ? 40 : panelHeight; - }, + } /** * _setClipRegion: @@ -2128,7 +2129,7 @@ Panel.prototype = { * @offset is only used during tweens. If provided, it is used to offset the * current position in order to calculate the exposed size. */ - _setClipRegion: function(hidden, offset) { + _setClipRegion(hidden, offset) { if (!this._shouldClipPanel()) { // important during monitor layout changes. this.actor.remove_clip(); // no-op if there wasn't any clipping to begin with. @@ -2192,9 +2193,9 @@ Panel.prototype = { } // Force the layout manager to update the input region Main.layoutManager.updateChrome() - }, + } - _shouldClipPanel: function() { + _shouldClipPanel() { const n_monitors = global.display.get_n_monitors(); if (n_monitors === 1) { @@ -2242,7 +2243,7 @@ Panel.prototype = { } return false; - }, + } /** * _moveResizePanel: @@ -2250,7 +2251,7 @@ Panel.prototype = { * Function to update the panel position, size, and clip region according to settings * values. Note that this is also called when the style changes. */ - _moveResizePanel: function() { + _moveResizePanel() { if (this._destroyed) return false; @@ -2400,9 +2401,9 @@ Panel.prototype = { if (AppletManager.appletsLoaded) this._setPanelHeight(); } return true; - }, + } - _set_orientation: function() { + _set_orientation() { // // cater for the style/alignment for different panel orientations // @@ -2414,9 +2415,9 @@ Panel.prototype = { this._set_vertical_panel_style(); this.is_vertical = true; } - }, + } - _set_vertical_panel_style: function() { + _set_vertical_panel_style() { this._leftBox.add_style_class_name('vertical'); this._leftBox.set_vertical(true); this._leftBox.set_x_align(Clutter.ActorAlign.FILL); @@ -2431,9 +2432,9 @@ Panel.prototype = { this._rightBox.set_vertical(true); this._rightBox.set_x_align(Clutter.ActorAlign.FILL); this._rightBox.set_y_align(Clutter.ActorAlign.END); - }, + } - _set_horizontal_panel_style: function() { + _set_horizontal_panel_style() { this._leftBox.remove_style_class_name('vertical'); this._leftBox.set_vertical(false); this._leftBox.set_x_align(Clutter.ActorAlign.START); @@ -2448,9 +2449,9 @@ Panel.prototype = { this._rightBox.set_vertical(false); this._rightBox.set_x_align(Clutter.ActorAlign.END); this._rightBox.set_y_align(Clutter.ActorAlign.FILL); - }, + } - _setPanelHeight: function() { + _setPanelHeight() { let height = setHeightForPanel(this); if (height === this.height) return; @@ -2460,9 +2461,9 @@ Panel.prototype = { this._onPanelZoneSizesChanged(); this.emit('size-changed', height); - }, + } - _createEmptyZoneSizes: function() { + _createEmptyZoneSizes() { let typeStruct = { "left" : 0, "center" : 0, @@ -2476,9 +2477,9 @@ Panel.prototype = { }; return sizes; - }, + } - _onPanelZoneSizesChanged: function(value, key) { + _onPanelZoneSizesChanged(value, key) { if (this._destroyed) return; let changed = false; @@ -2573,9 +2574,9 @@ Panel.prototype = { }); if (changed) this.emit('icon-size-changed'); - }, + } - _clampPanelZoneTextSize: function(panelZoneSizeSet, typeString, zoneString, defaults) { + _clampPanelZoneTextSize(panelZoneSizeSet, typeString, zoneString, defaults) { let iconSize = panelZoneSizeSet.maybeGet(zoneString); if (iconSize == undefined) { @@ -2587,9 +2588,9 @@ Panel.prototype = { } return iconSize; - }, + } - _clampPanelZoneColorIconSize: function(panelZoneSizeSet, typeString, zoneString, defaults) { + _clampPanelZoneColorIconSize(panelZoneSizeSet, typeString, zoneString, defaults) { let iconSize = panelZoneSizeSet.maybeGet(zoneString); if (iconSize == undefined) { @@ -2605,9 +2606,9 @@ Panel.prototype = { } return iconSize; // Always return a value above 0 or St will spam the log. - }, + } - _clampPanelZoneSymbolicIconSize: function(panelZoneSizeSet, typeString, zoneString, defaults) { + _clampPanelZoneSymbolicIconSize(panelZoneSizeSet, typeString, zoneString, defaults) { let iconSize = panelZoneSizeSet.maybeGet(zoneString); if (iconSize == undefined) { @@ -2618,9 +2619,9 @@ Panel.prototype = { let new_size = iconSize.clamp(MIN_SYMBOLIC_SIZE_PX, Math.min(MAX_SYMBOLIC_SIZE_PX, panelHeight)); return new_size; - }, + } - getPanelZoneIconSize: function(locationLabel, iconType) { + getPanelZoneIconSize(locationLabel, iconType) { let zoneConfig = this._panelZoneSizes; let typeString = "fullcolor"; @@ -2629,9 +2630,9 @@ Panel.prototype = { } return this._panelZoneSizes[typeString][locationLabel]; - }, + } - _removeZoneIconSizes: function() { + _removeZoneIconSizes() { let sizeSets = [ ["fullcolor", PANEL_ZONE_ICON_SIZES], ["symbolic", PANEL_ZONE_SYMBOLIC_ICON_SIZES], @@ -2662,9 +2663,9 @@ Panel.prototype = { }); global.log(`[Panel ${this.panelId}] Removing zone configuration`); - }, + } - _getPreferredWidth: function(actor, forHeight, alloc) { + _getPreferredWidth(actor, forHeight, alloc) { alloc.min_size = -1; alloc.natural_size = -1; @@ -2672,9 +2673,9 @@ Panel.prototype = { /* if (this.panelPosition == PanelLoc.top || this.panelPosition == PanelLoc.bottom) { alloc.natural_size = Main.layoutManager.primaryMonitor.width; } */ - }, + } - _getPreferredHeight: function(actor, forWidth, alloc) { + _getPreferredHeight(actor, forWidth, alloc) { alloc.min_size = -1; alloc.natural_size = -1; @@ -2683,7 +2684,7 @@ Panel.prototype = { alloc.natural_size = Main.layoutManager.primaryMonitor.height; alloc.natural_size = alloc.natural_size - this.toppanelHeight - this.bottompanelHeight - this.margin_top - this.margin_bottom; } */ - }, + } /** * _calcBoxSizes: @@ -2735,7 +2736,7 @@ Panel.prototype = { * * Returns (array): The left and right widths to be allocated. */ - _calcBoxSizes: function(allocWidth, allocHeight, vertical) { + _calcBoxSizes(allocWidth, allocHeight, vertical) { let leftBoundary, rightBoundary = 0; let leftMinWidth = 0; let leftNaturalWidth = 0; @@ -2861,17 +2862,17 @@ Panel.prototype = { } return [leftBoundary, rightBoundary]; - }, + } - _setVertChildbox: function(childbox, y1, y2) { + _setVertChildbox(childbox, y1, y2) { childbox.y1 = y1; childbox.y2 = y2; return; - }, + } - _setHorizChildbox: function(childbox, x1, x2, x1_rtl, x2_rtl) { + _setHorizChildbox(childbox, x1, x2, x1_rtl, x2_rtl) { if (this.actor.get_direction() == St.TextDirection.RTL) { childbox.x1 = x1_rtl; childbox.x2 = x2_rtl; @@ -2880,9 +2881,9 @@ Panel.prototype = { childbox.x2 = x2; } return; - }, + } - _allocate: function(actor, box, flags) { + _allocate(actor, box, flags) { let allocHeight = box.y2 - box.y1; let allocWidth = box.x2 - box.x1; @@ -2933,7 +2934,7 @@ Panel.prototype = { this._setHorizChildbox (childBox, rightBoundary, box.x2, box.x1, rightBoundary); this._rightBox.allocate(childBox, flags); } - }, + } /** * _panelHasOpenMenus: @@ -2941,7 +2942,7 @@ Panel.prototype = { * Checks if panel has open menus in the global.menuStack * @returns */ - _panelHasOpenMenus: function() { + _panelHasOpenMenus() { if (global.menuStack == null || global.menuStack.length == 0) return false; @@ -2955,7 +2956,7 @@ Panel.prototype = { } return false; - }, + } /** * _updatePanelVisibility: @@ -2966,7 +2967,7 @@ Panel.prototype = { * * true = autohide, false = always show, intel = Intelligent */ - _updatePanelVisibility: function() { + _updatePanelVisibility() { this._mouseEntered = this._mouseOnPanel(); if (this._panelEditMode || this._highlighted || this._peeking || this._panelHasOpenMenus()) @@ -3027,7 +3028,7 @@ Panel.prototype = { } this._queueShowHidePanel(); - }, + } /** * _queueShowHidePanel: @@ -3035,7 +3036,7 @@ Panel.prototype = { * Makes the panel show or hide after a delay specified by * panels-show-delay and panels-hide-delay. */ - _queueShowHidePanel: function() { + _queueShowHidePanel() { if (this._showHideTimer) { Mainloop.source_remove(this._showHideTimer); this._showHideTimer = 0; @@ -3056,18 +3057,18 @@ Panel.prototype = { let hideDelay = this._getProperty(PANEL_HIDE_DELAY_KEY, "i"); this._showHideTimer = Mainloop.timeout_add(hideDelay, Lang.bind(this, this._hidePanel)) } - }, + } - _enterPanel: function(actor=null, event=null) { + _enterPanel(actor=null, event=null) { if (!this._mouseEntered) { this._updatePanelVisibility(); } - }, + } - _leavePanel:function(actor=null, event=null) { + _leavePanel(actor=null, event=null) { // Panel gives false leave-event's when mouse is still on panel so we determine this._mouseEntered // manually with this._mouseOnPanel() in this._updatePanelVisibility() - + if (this._mouseEntered) { this._updatePanelVisibility(); if (this.isHideable() && event !== null && this._mouseOnPanel()) { @@ -3076,15 +3077,15 @@ Panel.prototype = { setTimeout(this._updatePanelVisibility.bind(this), 250); } } - }, + } - _mouseOnPanel: function() { + _mouseOnPanel() { this.actor.sync_hover(); const [x, y] = global.get_pointer(); return (this.actor.x <= x && x <= this.actor.x + this.actor.width && this.actor.y <= y && y <= this.actor.y + this.actor.height); - }, + } /** * disable: @@ -3092,7 +3093,7 @@ Panel.prototype = { * Disables the panel by settings the opacity to 0 and hides if autohide is * enable. The actor is then hidden after the animation. */ - disable: function() { + disable() { this._disabled = true; this.actor.ease({ opacity: 0, @@ -3102,14 +3103,14 @@ Panel.prototype = { this.actor.hide(); } }); - }, + } /** * enable: * * Reverses the effects of the disable function. */ - enable: function() { + enable() { this._disabled = false; this.actor.show(); this.actor.ease({ @@ -3117,7 +3118,7 @@ Panel.prototype = { duration: AUTOHIDE_ANIMATION_TIME, mode: Clutter.AnimationMode.EASE_OUT_QUAD }); - }, + } /** * _showPanel: @@ -3125,7 +3126,7 @@ Panel.prototype = { * A function to force the panel to show. This has no effect if the panel * is disabled. */ - _showPanel: function() { + _showPanel() { this._showHideTimer = 0; if (this._disabled) return; @@ -3181,14 +3182,14 @@ Panel.prototype = { this._rightBox.ease(boxParams); this._hidden = false; - }, + } /** * _hidePanel: * * This hides the panel. */ - _hidePanel: function() { + _hidePanel() { if (this._destroyed) return; this._showHideTimer = 0; @@ -3242,13 +3243,13 @@ Panel.prototype = { this._rightBox.ease(boxParams); this._hidden = true; - }, + } - getIsVisible: function() { + getIsVisible() { return !this._hidden || this._shouldShow; - }, + } - resetDNDZones: function() { + resetDNDZones() { this._leftBoxDNDHandler.reset(); this._centerBoxDNDHandler.reset(); this._rightBoxDNDHandler.reset(); From c90bc555d632a46189232e6ee8b7038f77dea922 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Tue, 24 Feb 2026 17:21:09 -0800 Subject: [PATCH 09/13] Rebase on git master --- data/theme/cinnamon-sass/widgets/_panel.scss | 6 + js/ui/applet.js | 2 +- js/ui/appletManager.js | 2 +- js/ui/cinnamonDBus.js | 9 + js/ui/panel.js | 387 +++++++++++++++---- 5 files changed, 329 insertions(+), 77 deletions(-) diff --git a/data/theme/cinnamon-sass/widgets/_panel.scss b/data/theme/cinnamon-sass/widgets/_panel.scss index 0d8a9b25cb..8c4f5f3d5b 100644 --- a/data/theme/cinnamon-sass/widgets/_panel.scss +++ b/data/theme/cinnamon-sass/widgets/_panel.scss @@ -11,6 +11,8 @@ &Left { spacing: 4px; + // background-color: blue; + &:dnd { background-color: rgba(255,0,0,0.2); } // For panel edit mode &:ltr { padding-right: 4px; } &:rtl { padding-left: 4px; } @@ -24,6 +26,8 @@ &Right { + // background-color: red; + &:dnd { background-color: rgba(0,0,255,0.2); } &:ltr { @@ -52,6 +56,8 @@ &Center { spacing: 4px; + // background-color: green; + &:dnd { background-color: rgba(0,255,0,0.2); } &.vertical { diff --git a/js/ui/applet.js b/js/ui/applet.js index ced548e926..fe00510236 100644 --- a/js/ui/applet.js +++ b/js/ui/applet.js @@ -656,7 +656,7 @@ var Applet = class Applet { } get _panelHeight() { - return this.panel.height; + return this.panel.heightForZones; } get _scaleMode() { diff --git a/js/ui/appletManager.js b/js/ui/appletManager.js index b7338f4fa2..b038e05ac4 100644 --- a/js/ui/appletManager.js +++ b/js/ui/appletManager.js @@ -597,7 +597,7 @@ function createApplet(extension, appletDefinition, panel = null) { // FIXME: Panel height is now available before an applet is initialized, // so we don't need to pass it to the constructor anymore, but would // require a compatibility clean-up effort. - applet = extension.module.main(extension.meta, orientation, panel.height, applet_id); + applet = extension.module.main(extension.meta, orientation, panel.heightForZone, applet_id); } catch (e) { Extension.logError(`Failed to evaluate 'main' function on applet: ${uuid}/${applet_id}`, uuid, e); return null; diff --git a/js/ui/cinnamonDBus.js b/js/ui/cinnamonDBus.js index f641559215..3c3250ac06 100644 --- a/js/ui/cinnamonDBus.js +++ b/js/ui/cinnamonDBus.js @@ -359,6 +359,15 @@ CinnamonDBus.prototype = { }, highlightPanel: function(id, highlight) { + global.log("Panel Id " + id); + let hasId = Main.panelManager.panels[id]; + global.log("Have iD: " + hasId); + // Main.panelManager.panels.forEach((panel) => { + // global.log("The panels id is: " + panel.Id); + // }) + // for (const element of Main.panelManager.panels) { + // global.log(element[id]); + // } if (Main.panelManager.panels[id]) Main.panelManager.panels[id].highlight(highlight); }, diff --git a/js/ui/panel.js b/js/ui/panel.js index 7f61da3994..b4a2223c9b 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -361,6 +361,7 @@ var PanelManager = GObject.registerClass({ this._addOsd.hide(); this._moveOsd.hide(); + this._onPanelsEnabledChanged(); this._checkCanAddPanel(); this._updateAllPointerBarriers(); } @@ -557,6 +558,7 @@ var PanelManager = GObject.registerClass({ */ removePanel(panelId) { this.panelCount -= 1; + global.log("Removing panel with panelId of: " + panelId); let list = getPanelsEnabledList(); for (let i = 0, len = list.length; i < len; i++) { if (list[i].split(":")[0] == panelId) { @@ -764,7 +766,7 @@ var PanelManager = GObject.registerClass({ * Returns (Panel.Panel): Panel created */ _loadPanel(ID, monitorIndex, panelPosition, panelList, metaList) { - + global.log("Loading panel with ID: " + ID); if (!panelList) panelList = this.panels; if (!metaList) metaList = this.panelsMeta; @@ -847,6 +849,7 @@ var PanelManager = GObject.registerClass({ let newMeta = new Array(this.panels.length); let panelProperties = getPanelsEnabledList(); + global.log("The current panelProperties are: " + panelProperties); for (let i = 0; i < panelProperties.length; i ++) { @@ -861,10 +864,14 @@ var PanelManager = GObject.registerClass({ let mon = parseInt(elements[1]); let ploc = getPanelLocFromName(elements[2]); + global.log("Panels enabled changed panel ID: " + ID); + if (this.panels[ID]) { // If (existing) panel is moved newMeta[ID] = [mon, ploc]; //Note: meta [i][0] is the monitor meta [i][1] is the panelposition newPanels[ID] = this.panels[ID]; // Move panel object to newPanels + global.log("About to delete panel: " + ID); + global.log(this.panels[ID]); this.panels[ID] = null; // avoids triggering the destroy logic that follows delete this.panels[ID]; @@ -892,6 +899,7 @@ var PanelManager = GObject.registerClass({ let removedPanelIndexes = []; for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i]) { + global.log("Getting ready to destroy: " + this.panels[i]); this.panels[i].destroy(); removedPanelIndexes.push(i); } @@ -1514,14 +1522,23 @@ var PanelZoneDNDHandler = class { * * This represents a panel on the screen. */ -// function Panel(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { -// this._init(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight); -// } -// Panel.prototype = { -var Panel = class { - constructor(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { +// var Panel = class { +var Panel = GObject.registerClass({ + Signals: { + 'size-changed': { param_types: [GObject.TYPE_INT] }, + 'icon-size-changed': {}, + }, +}, class Panel extends St.Widget { + _init(id, monitorIndex, panelPosition, toppanelHeight, bottompanelHeight) { + super._init({ + name: 'panel', + reactive: true, + }); + // this._delegate = this; + this.actor = this; + global.log("Creating a panel with a panel.Id of: " + id); this.panelId = id; this.monitorIndex = monitorIndex; this.monitor = global.display.get_monitor_geometry(monitorIndex); @@ -1541,7 +1558,7 @@ var Panel = class { this._monitorsChanged = false; this._mouseEntered = null; this._signalManager = new SignalManager.SignalManager(null); - this.height = 0; + this.heightForZones = 0; this.margin_top = 0; this.margin_bottom = 0; this.margin_left = 0; @@ -1556,7 +1573,7 @@ var Panel = class { this.themeSettings = new Gio.Settings({ schema_id: 'org.cinnamon.theme' }); - this.actor = new Cinnamon.GenericContainer({ name: 'panel', reactive: true }); + // this.actor = new Cinnamon.GenericContainer({ name: 'panel', reactive: true }); this.addPanelStyleClass(this.panelPosition); this.actor._delegate = this; @@ -1592,9 +1609,9 @@ var Panel = class { this.actor.connect('style-changed', Lang.bind(this, this._moveResizePanel)); this.actor.connect('leave-event', Lang.bind(this, this._leavePanel)); this.actor.connect('enter-event', Lang.bind(this, this._enterPanel)); - this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); - this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); - this.actor.connect('allocate', Lang.bind(this, this._allocate)); + // this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); + // this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); + // this.actor.connect('allocate', Lang.bind(this, this._allocate)); this.actor.connect('queue-relayout', () => this._setPanelHeight()); this._signalManager.connect(global.settings, "changed::" + PANEL_AUTOHIDE_KEY, this._processPanelAutoHide, this); @@ -2027,7 +2044,7 @@ var Panel = class { this._updatePanelVisibility(); } - this.actor.queue_relayout(); + this.queue_relayout(); } _onButtonPressEvent(actor, event) { @@ -2215,10 +2232,10 @@ var Panel = class { case PanelLoc.bottom: test_rect.x = this.actor.x; test_rect.width = this.actor.width; - test_rect.height = this.height; + test_rect.height = this.heightForZones; if (this.panelPosition === PanelLoc.top) { - test_rect.y = this.monitor.y - this.height; + test_rect.y = this.monitor.y - this.heightForZones; } else { test_rect.y = this.monitor.y + this.monitor.height; } @@ -2227,10 +2244,10 @@ var Panel = class { case PanelLoc.right: test_rect.y = this.actor.y; test_rect.height = this.actor.height; - test_rect.width = this.height; + test_rect.width = this.heightForZones; if (this.panelPosition === PanelLoc.left) { - test_rect.x = this.monitor.x - this.height; + test_rect.x = this.monitor.x - this.heightForZones; } else { test_rect.x = this.monitor.x + this.monitor.width; } @@ -2375,7 +2392,8 @@ var Panel = class { newX = this._hidden ? this.monitor.x + this.monitor.width - 1 : this.monitor.x + this.monitor.width - panelHeight; } - this.actor.set_size(panelHeight, newVertPanelHeight); + this.set_size(panelHeight, newVertPanelHeight); + global.log("------------ Setting actor size " + panelHeight + " " + newVertPanelHeight); } // update position and clip region @@ -2453,9 +2471,9 @@ var Panel = class { _setPanelHeight() { let height = setHeightForPanel(this); - if (height === this.height) return; + if (height === this.heightForZones) return; - this.height = height; + this.heightForZones = height; // In case icon sizes are responding to panel height this._onPanelZoneSizesChanged(); @@ -2535,7 +2553,7 @@ var Panel = class { * generate default display values for adding to this._panelZoneSizes, as well as a default item to add to * gsettings. */ if (!haveSettings) { - let panelHeight = this.height * global.ui_scale; + let panelHeight = this.heightForZones * global.ui_scale; let defaultForCache = { "left": getSizeFunc(defaults, typeString, "left", null), @@ -2597,7 +2615,7 @@ var Panel = class { iconSize = defaults[zoneString]; } - let height = this.height / global.ui_scale; + let height = this.heightForZones / global.ui_scale; if (iconSize === -1) { // Legacy: Scale to panel size iconSize = height; @@ -2615,7 +2633,7 @@ var Panel = class { iconSize = defaults[zoneString]; } - let panelHeight = this.height / global.ui_scale; + let panelHeight = this.heightForZones / global.ui_scale; let new_size = iconSize.clamp(MIN_SYMBOLIC_SIZE_PX, Math.min(MAX_SYMBOLIC_SIZE_PX, panelHeight)); return new_size; @@ -2665,26 +2683,26 @@ var Panel = class { global.log(`[Panel ${this.panelId}] Removing zone configuration`); } - _getPreferredWidth(actor, forHeight, alloc) { +// _getPreferredWidth(actor, forHeight, alloc) { - alloc.min_size = -1; - alloc.natural_size = -1; +// alloc.min_size = -1; +// alloc.natural_size = -1; - /* if (this.panelPosition == PanelLoc.top || this.panelPosition == PanelLoc.bottom) { - alloc.natural_size = Main.layoutManager.primaryMonitor.width; - } */ - } +// /* if (this.panelPosition == PanelLoc.top || this.panelPosition == PanelLoc.bottom) { +// alloc.natural_size = Main.layoutManager.primaryMonitor.width; +// } */ +// } - _getPreferredHeight(actor, forWidth, alloc) { +// _getPreferredHeight(actor, forWidth, alloc) { - alloc.min_size = -1; - alloc.natural_size = -1; +// alloc.min_size = -1; +// alloc.natural_size = -1; -/* if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { - alloc.natural_size = Main.layoutManager.primaryMonitor.height; - alloc.natural_size = alloc.natural_size - this.toppanelHeight - this.bottompanelHeight - this.margin_top - this.margin_bottom; - } */ - } +// /* if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { +// alloc.natural_size = Main.layoutManager.primaryMonitor.height; +// alloc.natural_size = alloc.natural_size - this.toppanelHeight - this.bottompanelHeight - this.margin_top - this.margin_bottom; +// } */ +// } /** * _calcBoxSizes: @@ -2883,59 +2901,278 @@ var Panel = class { return; } - _allocate(actor, box, flags) { - let allocHeight = box.y2 - box.y1; - let allocWidth = box.x2 - box.x1; + // vfunc_get_preferred_height(forWidth) { + // let [min, nat] = super.vfunc_get_preferred_height(forWidth); + // global.log("xxxxxxx This monitors height is " + this.monitor.height); + // if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) + // return [min, this.monitor.height]; + // else + // return [min, nat]; + // } + + // vfunc_get_preferred_width(forHeight) { + // let [min, nat] = super.vfunc_get_preferred_width(forHeight); + // global.log("xxxxxxx This monitors width is " + this.monitor.width); + // if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) + // return [min, nat]; + // else + // return [min, this.monitor.width]; + // } + + _calculateBoxes(allocWidth, allocHeight, isVertical) { + let leftBoundary = 0; + let rightBoundary = 0; + let leftMinWidth = 0; + let leftNaturalWidth = 0; + let rightMinWidth = 0; + let rightNaturalWidth = 0; + let centerMinWidth = 0; + let centerNaturalWidth = 0; - /* Left, center and right panel sections will fit inside this box, which is - equivalent to the CSS content-box (imaginary box inside borders and paddings) */ - let childBox = box.copy(); + let centerBoxOccupied = this._centerBox.get_n_children() > 0; - /* The boxes are layout managers, so they rubber-band around their contents and have a few - characteristics that they enforce on their contents. Of particular note is that the alignment - - LEFT, CENTER, RIGHT - is not independent of the fill as it probably ought to be, and that there - is this hybrid FILL alignment that also comes with implied left alignment (probably locale dependent). - Which is not a great problem when there is something in the box, but if there is nothing in the box and - something other than FILL alignment is chosen, then the boxes will have no size allocated. - Which is a bit of a bummer if you need to drag something into an empty box. So we need to work - around this. That's a manual size set when turning on edit mode, combined with adjustments after drop. - Note also that settings such as x_fill and y_fill only apply to the children of the box, not to the box itself */ + // global.log(isVertical); - if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { + if (isVertical) { + [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_height(-1); + [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_height(-1); + [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_height(-1); + } else { + [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_width(-1); + [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_width(-1); + [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_width(-1); + } + + // If in panel edit mode, give the center box a minimum width to allow a visual + // indicator of where to drag and drop + if (this._panelEditMode) { + centerBoxOccupied = true; + centerMinWidth = Math.max(centerMinWidth, EDIT_MODE_MIN_BOX_SIZE * global.ui_scale); + centerNaturalWidth = Math.max(centerNaturalWidth, EDIT_MODE_MIN_BOX_SIZE * global.ui_scale); + } + + let totalMinWidth = leftMinWidth + centerMinWidth + rightMinWidth; + let totalNaturalWidth = leftNaturalWidth + centerNaturalWidth + rightNaturalWidth; + + let sideMinWidth = Math.max(leftMinWidth, rightMinWidth); + let sideNaturalWidth = Math.max(leftNaturalWidth, rightNaturalWidth); + let totalCenteredMinWidth = centerMinWidth + 2 * sideMinWidth; + let totalCenteredNaturalWidth = centerNaturalWidth + 2 * sideNaturalWidth; + + let leftWidth, rightWidth; + + if (centerBoxOccupied) { + if (totalCenteredNaturalWidth < allocWidth) { + /* center the central box and butt the left and right up to it. */ + leftWidth = (allocWidth - centerNaturalWidth) / 2; + rightWidth = leftWidth; + } else if (totalCenteredMinWidth < allocWidth) { + /* Center can be centered as without shrinking things too much. + * First give everything the minWidth they want, and then + * distribute the remaining space proportional to how much the + * regions want. */ + let totalRemaining = allocWidth - totalCenteredMinWidth; + let totalWant = totalCenteredNaturalWidth - totalCenteredMinWidth; + + leftWidth = sideMinWidth + (sideNaturalWidth - sideMinWidth) / totalWant * totalRemaining; + rightWidth = leftWidth; + } else if (totalMinWidth < allocWidth) { + /* There is enough space for minWidth if we don't care about + * centering. Make center things as center as possible */ + if (leftMinWidth > rightMinWidth) { + leftWidth = leftMinWidth; + + if (leftMinWidth + centerNaturalWidth + rightNaturalWidth < allocWidth) { + rightWidth = allocWidth - leftMinWidth - centerNaturalWidth; + } else { + let totalRemaining = allocWidth - totalMinWidth; + let totalWant = centerNaturalWidth + rightNaturalWidth - (centerMinWidth + rightMinWidth); + + rightWidth = rightMinWidth; + if (totalWant > 0) + rightWidth += (rightNaturalWidth - rightMinWidth) / totalWant * totalRemaining; + } + } else { + rightWidth = rightMinWidth; - /* Distribute sizes for the allocated height with points relative to - the children allocation box, inside borders and paddings. */ - let [leftBoundary, rightBoundary] = this._calcBoxSizes(allocHeight, allocWidth, true); - leftBoundary += box.y1; - rightBoundary += box.y1; + if (rightMinWidth + centerNaturalWidth + leftNaturalWidth < allocWidth) { + leftWidth = allocWidth - rightMinWidth - centerNaturalWidth; + } else { + let totalRemaining = allocWidth - totalMinWidth; + let totalWant = centerNaturalWidth + leftNaturalWidth - (centerMinWidth + leftMinWidth); + + leftWidth = leftMinWidth; + if (totalWant > 0) + leftWidth += (leftNaturalWidth - leftMinWidth) / totalWant * totalRemaining; + } + } + } else { + /* Scale everything down according to their minWidth. */ + leftWidth = leftMinWidth / totalMinWidth * allocWidth; + rightWidth = rightMinWidth / totalMinWidth * allocWidth; + } + } else { // center box not occupied + if (totalNaturalWidth < allocWidth) { + /* Everything's fine. Allocate as usual. */ + if (isVertical) { + leftWidth = Math.max(leftNaturalWidth, leftMinWidth); + rightWidth = Math.max(rightNaturalWidth, rightMinWidth); + } else { + leftWidth = leftNaturalWidth; + rightWidth = rightNaturalWidth; + } + } else if (totalMinWidth < allocWidth) { + /* There is enough space for minWidth but not for naturalWidth. + * Allocate the minWidth and then divide the remaining space + * according to how much more they want. */ + let totalRemaining = allocWidth - totalMinWidth; + let totalWant = totalNaturalWidth - totalMinWidth; - this._setVertChildbox (childBox, box.y1, leftBoundary); + leftWidth = leftMinWidth + ((leftNaturalWidth - leftMinWidth) / totalWant) * totalRemaining; + rightWidth = rightMinWidth + ((rightNaturalWidth - rightMinWidth) / totalWant) * totalRemaining; + } else { + /* Scale everything down according to their minWidth. */ + leftWidth = leftMinWidth / totalMinWidth * allocWidth; + rightWidth = rightMinWidth / totalMinWidth * allocWidth; + } + } + + leftBoundary = Math.round(leftWidth); + rightBoundary = Math.round(allocWidth - rightWidth); + + return [leftBoundary, rightBoundary]; + } + + vfunc_allocate(box, flags) { + this.set_allocation(box, flags); + + const allocWidth = box.x2 - box.x1; + const allocHeight = box.y2 - box.y1; + + // global.log("panelId " + this.panelId); + // global.log("allocWidth " + allocWidth); + // global.log("allocHeight " + allocHeight); + + // const [, leftNaturalWidth] = this._leftBox.get_preferred_width(-1); + // const [, centerNaturalWidth] = this._centerBox.get_preferred_width(-1); + // const [, rightNaturalWidth] = this._rightBox.get_preferred_width(-1); + + // const centerWidth = centerNaturalWidth; + // const sideWidth = Math.max(0, (allocWidth - centerWidth) / 2); + + const childBox = new Clutter.ActorBox(); + + if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { + let [leftBoundary, rightBoundary] = this._calculateBoxes(allocHeight, allocWidth, true); + + // global.log("Sizes xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + // global.log("Left Boundary: " + leftBoundary); + // global.log("Right Boundary: " + rightBoundary); + // global.log("Alloc Width: " + allocWidth); + // global.log("Alloc Height: " + allocHeight); + childBox.y1 = 0; + childBox.y2 = leftBoundary; + childBox.x1 = 0; + childBox.x2 = allocWidth; this._leftBox.allocate(childBox, flags); - this._setVertChildbox (childBox, leftBoundary, rightBoundary); + childBox.y1 = leftBoundary; + childBox.y2 = rightBoundary; + childBox.x1 = 0; + childBox.x2 = allocWidth; this._centerBox.allocate(childBox, flags); - this._setVertChildbox (childBox, rightBoundary, box.y2); + childBox.y1 = rightBoundary; + childBox.y2 = allocHeight; + childBox.x1 = 0; + childBox.x2 = allocWidth; this._rightBox.allocate(childBox, flags); - } else { // horizontal panel - - /* Distribute sizes for the allocated width with points relative to - the children allocation box, inside borders and paddings. */ - let [leftBoundary, rightBoundary] = this._calcBoxSizes(allocWidth, allocHeight, false); - leftBoundary += box.x1; - rightBoundary += box.x1; - - this._setHorizChildbox (childBox, box.x1, leftBoundary, leftBoundary, box.x2); + } else { + let [leftBoundary, rightBoundary] = this._calculateBoxes(allocWidth, allocHeight, false); + // global.log(this.panelId); + // global.log("Sizes xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + // global.log("Left Boundary: " + leftBoundary); + // global.log("Right Boundary: " + rightBoundary); + childBox.y1 = 0; + childBox.y2 = allocHeight; + childBox.x1 = 0; + childBox.x2 = leftBoundary; + // childBox.x2 = Math.min(Math.floor(sideWidth), leftNaturalWidth); this._leftBox.allocate(childBox, flags); - this._setHorizChildbox (childBox, leftBoundary, rightBoundary, rightBoundary, leftBoundary); + childBox.y1 = 0; + childBox.y2 = allocHeight; + // childBox.x1 = Math.ceil(sideWidth); + childBox.x1 = leftBoundary; + // childBox.x2 = childBox.x1 + centerWidth; + childBox.x2 = rightBoundary; this._centerBox.allocate(childBox, flags); - this._setHorizChildbox (childBox, rightBoundary, box.x2, box.x1, rightBoundary); + childBox.y1 = 0; + childBox.y2 = allocHeight; + // childBox.x1 = Math.max(allocWidth - Math.min(Math.floor(sideWidth), rightNaturalWidth), 0); + childBox.x1 = rightBoundary; + childBox.x2 = allocWidth; this._rightBox.allocate(childBox, flags); } } + // _allocate(actor, box, flags) { + // // vfunc_allocate(box, flags) { + // // this.set_allocation(box, flags); + + // let allocHeight = box.y2 - box.y1; + // let allocWidth = box.x2 - box.x1; + + // /* Left, center and right panel sections will fit inside this box, which is + // equivalent to the CSS content-box (imaginary box inside borders and paddings) */ + // let childBox = box.copy(); + + // /* The boxes are layout managers, so they rubber-band around their contents and have a few + // characteristics that they enforce on their contents. Of particular note is that the alignment + // - LEFT, CENTER, RIGHT - is not independent of the fill as it probably ought to be, and that there + // is this hybrid FILL alignment that also comes with implied left alignment (probably locale dependent). + // Which is not a great problem when there is something in the box, but if there is nothing in the box and + // something other than FILL alignment is chosen, then the boxes will have no size allocated. + // Which is a bit of a bummer if you need to drag something into an empty box. So we need to work + // around this. That's a manual size set when turning on edit mode, combined with adjustments after drop. + // Note also that settings such as x_fill and y_fill only apply to the children of the box, not to the box itself */ + + // if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { + + // /* Distribute sizes for the allocated height with points relative to + // the children allocation box, inside borders and paddings. */ + // let [leftBoundary, rightBoundary] = this._calcBoxSizes(allocHeight, allocWidth, true); + // leftBoundary += box.y1; + // rightBoundary += box.y1; + + // this._setVertChildbox (childBox, box.y1, leftBoundary); + // this._leftBox.allocate(childBox, flags); + + // this._setVertChildbox (childBox, leftBoundary, rightBoundary); + // this._centerBox.allocate(childBox, flags); + + // this._setVertChildbox (childBox, rightBoundary, box.y2); + // this._rightBox.allocate(childBox, flags); + // } else { // horizontal panel + + // /* Distribute sizes for the allocated width with points relative to + // the children allocation box, inside borders and paddings. */ + // let [leftBoundary, rightBoundary] = this._calcBoxSizes(allocWidth, allocHeight, false); + // leftBoundary += box.x1; + // rightBoundary += box.x1; + + // this._setHorizChildbox (childBox, box.x1, leftBoundary, leftBoundary, box.x2); + // this._leftBox.allocate(childBox, flags); + + // this._setHorizChildbox (childBox, leftBoundary, rightBoundary, rightBoundary, leftBoundary); + // this._centerBox.allocate(childBox, flags); + + // this._setHorizChildbox (childBox, rightBoundary, box.x2, box.x1, rightBoundary); + // this._rightBox.allocate(childBox, flags); + // } + // } + /** * _panelHasOpenMenus: * @@ -3254,6 +3491,6 @@ var Panel = class { this._centerBoxDNDHandler.reset(); this._rightBoxDNDHandler.reset(); } -}; +}); -Signals.addSignalMethods(Panel.prototype); +// Signals.addSignalMethods(Panel.prototype); From 3c6b7ae8431dcb12e22011f367a99c6fcdf2c553 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Sat, 28 Feb 2026 11:02:55 -0800 Subject: [PATCH 10/13] panel.js: Port the panel to St.Widget This removes another major use of CinnamonGenericContainer. This could be taken even further, but trying to break as little as possible with this change. --- data/theme/cinnamon-sass/widgets/_panel.scss | 6 - js/ui/cinnamonDBus.js | 9 - js/ui/panel.js | 446 ++++--------------- 3 files changed, 88 insertions(+), 373 deletions(-) diff --git a/data/theme/cinnamon-sass/widgets/_panel.scss b/data/theme/cinnamon-sass/widgets/_panel.scss index 8c4f5f3d5b..0d8a9b25cb 100644 --- a/data/theme/cinnamon-sass/widgets/_panel.scss +++ b/data/theme/cinnamon-sass/widgets/_panel.scss @@ -11,8 +11,6 @@ &Left { spacing: 4px; - // background-color: blue; - &:dnd { background-color: rgba(255,0,0,0.2); } // For panel edit mode &:ltr { padding-right: 4px; } &:rtl { padding-left: 4px; } @@ -26,8 +24,6 @@ &Right { - // background-color: red; - &:dnd { background-color: rgba(0,0,255,0.2); } &:ltr { @@ -56,8 +52,6 @@ &Center { spacing: 4px; - // background-color: green; - &:dnd { background-color: rgba(0,255,0,0.2); } &.vertical { diff --git a/js/ui/cinnamonDBus.js b/js/ui/cinnamonDBus.js index 3c3250ac06..f641559215 100644 --- a/js/ui/cinnamonDBus.js +++ b/js/ui/cinnamonDBus.js @@ -359,15 +359,6 @@ CinnamonDBus.prototype = { }, highlightPanel: function(id, highlight) { - global.log("Panel Id " + id); - let hasId = Main.panelManager.panels[id]; - global.log("Have iD: " + hasId); - // Main.panelManager.panels.forEach((panel) => { - // global.log("The panels id is: " + panel.Id); - // }) - // for (const element of Main.panelManager.panels) { - // global.log(element[id]); - // } if (Main.panelManager.panels[id]) Main.panelManager.panels[id].highlight(highlight); }, diff --git a/js/ui/panel.js b/js/ui/panel.js index b4a2223c9b..95a5b28851 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -10,7 +10,6 @@ const Cairo = imports.cairo; const Clutter = imports.gi.Clutter; const GObject = imports.gi.GObject; -const Lang = imports.lang; const Mainloop = imports.mainloop; const Meta = imports.gi.Meta; const Pango = imports.gi.Pango; @@ -361,7 +360,6 @@ var PanelManager = GObject.registerClass({ this._addOsd.hide(); this._moveOsd.hide(); - this._onPanelsEnabledChanged(); this._checkCanAddPanel(); this._updateAllPointerBarriers(); } @@ -446,10 +444,10 @@ var PanelManager = GObject.registerClass({ let pleft, pright; for (let j = 0, len = stash.length; j < len; j++) { if (stash[j][2] == PanelLoc.left && stash[j][1] == i) { - pleft = this._loadPanel(stash[j][0], stash[j][1], stash[j][2], [true,true]); + pleft = this._loadPanel(stash[j][0], stash[j][1], stash[j][2]); } if (stash[j][2] == PanelLoc.right && stash[j][1] == i) { - pright = this._loadPanel(stash[j][0], stash[j][1], stash[j][2], [true,true]); + pright = this._loadPanel(stash[j][0], stash[j][1], stash[j][2]); } if (stash[j][2] == PanelLoc.bottom && stash[j][1] == i) { this._loadPanel(stash[j][0], stash[j][1], stash[j][2]); @@ -558,7 +556,6 @@ var PanelManager = GObject.registerClass({ */ removePanel(panelId) { this.panelCount -= 1; - global.log("Removing panel with panelId of: " + panelId); let list = getPanelsEnabledList(); for (let i = 0, len = list.length; i < len; i++) { if (list[i].split(":")[0] == panelId) { @@ -766,7 +763,6 @@ var PanelManager = GObject.registerClass({ * Returns (Panel.Panel): Panel created */ _loadPanel(ID, monitorIndex, panelPosition, panelList, metaList) { - global.log("Loading panel with ID: " + ID); if (!panelList) panelList = this.panels; if (!metaList) metaList = this.panelsMeta; @@ -849,8 +845,6 @@ var PanelManager = GObject.registerClass({ let newMeta = new Array(this.panels.length); let panelProperties = getPanelsEnabledList(); - global.log("The current panelProperties are: " + panelProperties); - for (let i = 0; i < panelProperties.length; i ++) { let elements = panelProperties[i].split(":"); @@ -864,14 +858,10 @@ var PanelManager = GObject.registerClass({ let mon = parseInt(elements[1]); let ploc = getPanelLocFromName(elements[2]); - global.log("Panels enabled changed panel ID: " + ID); - if (this.panels[ID]) { // If (existing) panel is moved newMeta[ID] = [mon, ploc]; //Note: meta [i][0] is the monitor meta [i][1] is the panelposition newPanels[ID] = this.panels[ID]; // Move panel object to newPanels - global.log("About to delete panel: " + ID); - global.log(this.panels[ID]); this.panels[ID] = null; // avoids triggering the destroy logic that follows delete this.panels[ID]; @@ -899,7 +889,6 @@ var PanelManager = GObject.registerClass({ let removedPanelIndexes = []; for (let i = 0, len = this.panels.length; i < len; i++) { if (this.panels[i]) { - global.log("Getting ready to destroy: " + this.panels[i]); this.panels[i].destroy(); removedPanelIndexes.push(i); } @@ -1510,7 +1499,6 @@ var PanelZoneDNDHandler = class { * * @monitor (Meta.Rectangle): the geometry (bounding box) of the monitor * @panelPosition (integer): where the panel is on the screen - * @actor (Cinnamon.GenericContainer): the actor of the panel * * @_leftBox (St.BoxLayout): the box containing all the applets in the left region * @_centerBox (St.BoxLayout): the box containing all the applets in the center region @@ -1522,8 +1510,6 @@ var PanelZoneDNDHandler = class { * * This represents a panel on the screen. */ - -// var Panel = class { var Panel = GObject.registerClass({ Signals: { 'size-changed': { param_types: [GObject.TYPE_INT] }, @@ -1535,10 +1521,9 @@ var Panel = GObject.registerClass({ name: 'panel', reactive: true, }); - // this._delegate = this; + // Keeping this to avoid breaking things this.actor = this; - global.log("Creating a panel with a panel.Id of: " + id); this.panelId = id; this.monitorIndex = monitorIndex; this.monitor = global.display.get_monitor_geometry(monitorIndex); @@ -1572,31 +1557,28 @@ var Panel = GObject.registerClass({ this._peeking = false; this.themeSettings = new Gio.Settings({ schema_id: 'org.cinnamon.theme' }); - - // this.actor = new Cinnamon.GenericContainer({ name: 'panel', reactive: true }); this.addPanelStyleClass(this.panelPosition); this.actor._delegate = this; this._menus = new PopupMenu.PopupMenuManager(this); - this._leftBox = new St.BoxLayout({ name: 'panelLeft', style_class: 'panelLeft', important: true }); - this._rightBox = new St.BoxLayout({ name: 'panelRight', style_class: 'panelRight', important: true }); - this._centerBox = new St.BoxLayout({ name: 'panelCenter', style_class: 'panelCenter', important: true }); + this._leftBox = new St.BoxLayout({ name: 'panelLeft', style_class: 'panelLeft', important: true }); + this._rightBox = new St.BoxLayout({ name: 'panelRight', style_class: 'panelRight', important: true }); + this._centerBox = new St.BoxLayout({ name: 'panelCenter', style_class: 'panelCenter', important: true }); - if (this.is_vertical) { + if (this.is_vertical) this._set_vertical_panel_style(); - } else { + else this._set_horizontal_panel_style(); - } this.actor.add_actor(this._leftBox); this.actor.add_actor(this._centerBox); this.actor.add_actor(this._rightBox); - this._leftBoxDNDHandler = new PanelZoneDNDHandler(this._leftBox, 'left', this.panelId); + this._leftBoxDNDHandler = new PanelZoneDNDHandler(this._leftBox, 'left', this.panelId); this._centerBoxDNDHandler = new PanelZoneDNDHandler(this._centerBox, 'center', this.panelId); - this._rightBoxDNDHandler = new PanelZoneDNDHandler(this._rightBox, 'right', this.panelId); + this._rightBoxDNDHandler = new PanelZoneDNDHandler(this._rightBox, 'right', this.panelId); this.addContextMenuToPanel(this.panelPosition); @@ -1605,13 +1587,6 @@ var Panel = GObject.registerClass({ this._onPanelEditModeChanged(); this._processPanelAutoHide(); - this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent)); - this.actor.connect('style-changed', Lang.bind(this, this._moveResizePanel)); - this.actor.connect('leave-event', Lang.bind(this, this._leavePanel)); - this.actor.connect('enter-event', Lang.bind(this, this._enterPanel)); - // this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth)); - // this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight)); - // this.actor.connect('allocate', Lang.bind(this, this._allocate)); this.actor.connect('queue-relayout', () => this._setPanelHeight()); this._signalManager.connect(global.settings, "changed::" + PANEL_AUTOHIDE_KEY, this._processPanelAutoHide, this); @@ -1746,7 +1721,7 @@ var Panel = GObject.registerClass({ this._menus = null; this.monitor = null; - return; + super.destroy(); } peekPanel() { @@ -1856,7 +1831,7 @@ var Panel = GObject.registerClass({ if (this._dragShowId && this._dragShowId > 0) Mainloop.source_remove(this._dragShowId); - let leaveIfOut = Lang.bind(this, function() { + let leaveIfOut = () => { this._dragShowId = 0; let [x, y, whatever] = global.get_pointer(); this.actor.sync_hover(); @@ -1868,7 +1843,7 @@ var Panel = GObject.registerClass({ this._leavePanel(); return false; } - }); // end of bind + }; this._dragShowId = Mainloop.timeout_add(500, leaveIfOut); @@ -2047,19 +2022,19 @@ var Panel = GObject.registerClass({ this.queue_relayout(); } - _onButtonPressEvent(actor, event) { - if (event.get_button() == 1) { + vfunc_button_press_event(event) { + if (event.button === 1) { if (this._context_menu.isOpen) this._context_menu.toggle(); } - if (event.get_button() == 3) { // right click + if (event.button === 3) { try { - let [x, y] = event.get_coords(); + let { x, y } = event; let target = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y); // NB test on parent fails with centre aligned vertical box, but works for the test against the actor if (this._context_menu._getMenuItems().length > 0 && - (target.get_parent() == this.actor || target == this.actor)) { + (target.get_parent() === this || target === this)) { if (!this._context_menu.isOpen) { switch (this.panelPosition) { case PanelLoc.top: @@ -2079,7 +2054,8 @@ var Panel = GObject.registerClass({ global.log(e); } } - return; + + return Clutter.EVENT_STOP; } _onFocusChanged() { @@ -2262,6 +2238,12 @@ var Panel = GObject.registerClass({ return false; } + vfunc_style_changed() { + super.vfunc_style_changed(); + + this._moveResizePanel(); + } + /** * _moveResizePanel: * @@ -2393,7 +2375,6 @@ var Panel = GObject.registerClass({ : this.monitor.x + this.monitor.width - panelHeight; } this.set_size(panelHeight, newVertPanelHeight); - global.log("------------ Setting actor size " + panelHeight + " " + newVertPanelHeight); } // update position and clip region @@ -2683,32 +2664,11 @@ var Panel = GObject.registerClass({ global.log(`[Panel ${this.panelId}] Removing zone configuration`); } -// _getPreferredWidth(actor, forHeight, alloc) { - -// alloc.min_size = -1; -// alloc.natural_size = -1; - -// /* if (this.panelPosition == PanelLoc.top || this.panelPosition == PanelLoc.bottom) { -// alloc.natural_size = Main.layoutManager.primaryMonitor.width; -// } */ -// } - -// _getPreferredHeight(actor, forWidth, alloc) { - -// alloc.min_size = -1; -// alloc.natural_size = -1; - -// /* if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { -// alloc.natural_size = Main.layoutManager.primaryMonitor.height; -// alloc.natural_size = alloc.natural_size - this.toppanelHeight - this.bottompanelHeight - this.margin_top - this.margin_bottom; -// } */ -// } - /** - * _calcBoxSizes: + * _calculateBoxes: * @allocWidth (real): allocated total width * @allocHeight (real): allocated total height - * @vertical (boolean): if on vertical panel + * @isVertical (boolean): if on vertical panel * * Given the minimum and natural width requested by each box, this function * calculates how much width should actually allocated to each box. The @@ -2754,189 +2714,22 @@ var Panel = GObject.registerClass({ * * Returns (array): The left and right widths to be allocated. */ - _calcBoxSizes(allocWidth, allocHeight, vertical) { - let leftBoundary, rightBoundary = 0; - let leftMinWidth = 0; - let leftNaturalWidth = 0; - let rightMinWidth = 0; - let rightNaturalWidth = 0; - let centerMinWidth = 0; - let centerNaturalWidth = 0; - - if (vertical) - { - [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_height(-1); - [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_height(-1); - [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_height(-1); - } else { - [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_width(-1); - [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_width(-1); - [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_width(-1); - } - - let centerBoxOccupied = this._centerBox.get_n_children() > 0; - - /* If panel edit mode, pretend central box is occupied and give it at - * least a minimum width so that things can be dropped into it. - Note that this has to be combined with the box being given Clutter.ActorAlign.FILL */ - if (this._panelEditMode) { - centerBoxOccupied = true; - centerMinWidth = Math.max(centerMinWidth, EDIT_MODE_MIN_BOX_SIZE * global.ui_scale); - centerNaturalWidth = Math.max(centerNaturalWidth, EDIT_MODE_MIN_BOX_SIZE * global.ui_scale); - } - - let totalMinWidth = leftMinWidth + centerMinWidth + rightMinWidth; - let totalNaturalWidth = leftNaturalWidth + centerNaturalWidth + rightNaturalWidth; - - let sideMinWidth = Math.max(leftMinWidth, rightMinWidth); - let sideNaturalWidth = Math.max(leftNaturalWidth, rightNaturalWidth); - let totalCenteredMinWidth = centerMinWidth + 2 * sideMinWidth; - let totalCenteredNaturalWidth = centerNaturalWidth + 2 * sideNaturalWidth; - - let leftWidth, rightWidth; - - if (centerBoxOccupied) { - if (totalCenteredNaturalWidth < allocWidth) { - /* center the central box and butt the left and right up to it. */ - leftWidth = (allocWidth - centerNaturalWidth) / 2; - rightWidth = leftWidth; - } else if (totalCenteredMinWidth < allocWidth) { - /* Center can be centered as without shrinking things too much. - * First give everything the minWidth they want, and then - * distribute the remaining space proportional to how much the - * regions want. */ - let totalRemaining = allocWidth - totalCenteredMinWidth; - let totalWant = totalCenteredNaturalWidth - totalCenteredMinWidth; - - leftWidth = sideMinWidth + (sideNaturalWidth - sideMinWidth) / totalWant * totalRemaining; - rightWidth = leftWidth; - } else if (totalMinWidth < allocWidth) { - /* There is enough space for minWidth if we don't care about - * centering. Make center things as center as possible */ - if (leftMinWidth > rightMinWidth) { - leftWidth = leftMinWidth; - - if (leftMinWidth + centerNaturalWidth + rightNaturalWidth < allocWidth) { - rightWidth = allocWidth - leftMinWidth - centerNaturalWidth; - } else { - let totalRemaining = allocWidth - totalMinWidth; - let totalWant = centerNaturalWidth + rightNaturalWidth - (centerMinWidth + rightMinWidth); - - rightWidth = rightMinWidth; - if (totalWant > 0) - rightWidth += (rightNaturalWidth - rightMinWidth) / totalWant * totalRemaining; - } - } else { - rightWidth = rightMinWidth; - - if (rightMinWidth + centerNaturalWidth + leftNaturalWidth < allocWidth) { - leftWidth = allocWidth - rightMinWidth - centerNaturalWidth; - } else { - let totalRemaining = allocWidth - totalMinWidth; - let totalWant = centerNaturalWidth + leftNaturalWidth - (centerMinWidth + leftMinWidth); - - leftWidth = leftMinWidth; - if (totalWant > 0) - leftWidth += (leftNaturalWidth - leftMinWidth) / totalWant * totalRemaining; - } - } - } else { - /* Scale everything down according to their minWidth. */ - leftWidth = leftMinWidth / totalMinWidth * allocWidth; - rightWidth = rightMinWidth / totalMinWidth * allocWidth; - } - } else { // center box not occupied - if (totalNaturalWidth < allocWidth) { - /* Everything's fine. Allocate as usual. */ - if (vertical) { - leftWidth = Math.max(leftNaturalWidth, leftMinWidth); - rightWidth = Math.max(rightNaturalWidth, rightMinWidth); - } else { - leftWidth = leftNaturalWidth; - rightWidth = rightNaturalWidth; - } - } else if (totalMinWidth < allocWidth) { - /* There is enough space for minWidth but not for naturalWidth. - * Allocate the minWidth and then divide the remaining space - * according to how much more they want. */ - let totalRemaining = allocWidth - totalMinWidth; - let totalWant = totalNaturalWidth - totalMinWidth; - - leftWidth = leftMinWidth + ((leftNaturalWidth - leftMinWidth) / totalWant) * totalRemaining; - rightWidth = rightMinWidth + ((rightNaturalWidth - rightMinWidth) / totalWant) * totalRemaining; - } else { - /* Scale everything down according to their minWidth. */ - leftWidth = leftMinWidth / totalMinWidth * allocWidth; - rightWidth = rightMinWidth / totalMinWidth * allocWidth; - } - } - - leftBoundary = Math.round(leftWidth); - rightBoundary = Math.round(allocWidth - rightWidth); - - if (!vertical && (this.actor.get_direction() === St.TextDirection.RTL)) { - leftBoundary = Math.round(allocWidth - leftWidth); - rightBoundary = Math.round(rightWidth); - } - - return [leftBoundary, rightBoundary]; - } - - _setVertChildbox(childbox, y1, y2) { - - childbox.y1 = y1; - childbox.y2 = y2; - - return; - } - - _setHorizChildbox(childbox, x1, x2, x1_rtl, x2_rtl) { - if (this.actor.get_direction() == St.TextDirection.RTL) { - childbox.x1 = x1_rtl; - childbox.x2 = x2_rtl; - } else { - childbox.x1 = x1; - childbox.x2 = x2; - } - return; - } - - // vfunc_get_preferred_height(forWidth) { - // let [min, nat] = super.vfunc_get_preferred_height(forWidth); - // global.log("xxxxxxx This monitors height is " + this.monitor.height); - // if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) - // return [min, this.monitor.height]; - // else - // return [min, nat]; - // } - - // vfunc_get_preferred_width(forHeight) { - // let [min, nat] = super.vfunc_get_preferred_width(forHeight); - // global.log("xxxxxxx This monitors width is " + this.monitor.width); - // if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) - // return [min, nat]; - // else - // return [min, this.monitor.width]; - // } - _calculateBoxes(allocWidth, allocHeight, isVertical) { let leftBoundary = 0; let rightBoundary = 0; - let leftMinWidth = 0; - let leftNaturalWidth = 0; - let rightMinWidth = 0; - let rightNaturalWidth = 0; - let centerMinWidth = 0; + let leftMinWidth = 0; + let leftNaturalWidth = 0; + let rightMinWidth = 0; + let rightNaturalWidth = 0; + let centerMinWidth = 0; let centerNaturalWidth = 0; let centerBoxOccupied = this._centerBox.get_n_children() > 0; - // global.log(isVertical); - if (isVertical) { - [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_height(-1); + [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_height(-1); [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_height(-1); - [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_height(-1); + [rightMinWidth, rightNaturalWidth] = this._rightBox.get_preferred_height(-1); } else { [leftMinWidth, leftNaturalWidth] = this._leftBox.get_preferred_width(-1); [centerMinWidth, centerNaturalWidth] = this._centerBox.get_preferred_width(-1); @@ -2951,12 +2744,12 @@ var Panel = GObject.registerClass({ centerNaturalWidth = Math.max(centerNaturalWidth, EDIT_MODE_MIN_BOX_SIZE * global.ui_scale); } - let totalMinWidth = leftMinWidth + centerMinWidth + rightMinWidth; - let totalNaturalWidth = leftNaturalWidth + centerNaturalWidth + rightNaturalWidth; + let totalMinWidth = leftMinWidth + centerMinWidth + rightMinWidth; + let totalNaturalWidth = leftNaturalWidth + centerNaturalWidth + rightNaturalWidth; - let sideMinWidth = Math.max(leftMinWidth, rightMinWidth); - let sideNaturalWidth = Math.max(leftNaturalWidth, rightNaturalWidth); - let totalCenteredMinWidth = centerMinWidth + 2 * sideMinWidth; + let sideMinWidth = Math.max(leftMinWidth, rightMinWidth); + let sideNaturalWidth = Math.max(leftNaturalWidth, rightNaturalWidth); + let totalCenteredMinWidth = centerMinWidth + 2 * sideMinWidth; let totalCenteredNaturalWidth = centerNaturalWidth + 2 * sideNaturalWidth; let leftWidth, rightWidth; @@ -2964,7 +2757,7 @@ var Panel = GObject.registerClass({ if (centerBoxOccupied) { if (totalCenteredNaturalWidth < allocWidth) { /* center the central box and butt the left and right up to it. */ - leftWidth = (allocWidth - centerNaturalWidth) / 2; + leftWidth = (allocWidth - centerNaturalWidth) / 2; rightWidth = leftWidth; } else if (totalCenteredMinWidth < allocWidth) { /* Center can be centered as without shrinking things too much. @@ -2972,7 +2765,7 @@ var Panel = GObject.registerClass({ * distribute the remaining space proportional to how much the * regions want. */ let totalRemaining = allocWidth - totalCenteredMinWidth; - let totalWant = totalCenteredNaturalWidth - totalCenteredMinWidth; + let totalWant = totalCenteredNaturalWidth - totalCenteredMinWidth; leftWidth = sideMinWidth + (sideNaturalWidth - sideMinWidth) / totalWant * totalRemaining; rightWidth = leftWidth; @@ -2986,7 +2779,7 @@ var Panel = GObject.registerClass({ rightWidth = allocWidth - leftMinWidth - centerNaturalWidth; } else { let totalRemaining = allocWidth - totalMinWidth; - let totalWant = centerNaturalWidth + rightNaturalWidth - (centerMinWidth + rightMinWidth); + let totalWant = centerNaturalWidth + rightNaturalWidth - (centerMinWidth + rightMinWidth); rightWidth = rightMinWidth; if (totalWant > 0) @@ -2999,7 +2792,7 @@ var Panel = GObject.registerClass({ leftWidth = allocWidth - rightMinWidth - centerNaturalWidth; } else { let totalRemaining = allocWidth - totalMinWidth; - let totalWant = centerNaturalWidth + leftNaturalWidth - (centerMinWidth + leftMinWidth); + let totalWant = centerNaturalWidth + leftNaturalWidth - (centerMinWidth + leftMinWidth); leftWidth = leftMinWidth; if (totalWant > 0) @@ -3008,17 +2801,17 @@ var Panel = GObject.registerClass({ } } else { /* Scale everything down according to their minWidth. */ - leftWidth = leftMinWidth / totalMinWidth * allocWidth; + leftWidth = leftMinWidth / totalMinWidth * allocWidth; rightWidth = rightMinWidth / totalMinWidth * allocWidth; } } else { // center box not occupied if (totalNaturalWidth < allocWidth) { /* Everything's fine. Allocate as usual. */ if (isVertical) { - leftWidth = Math.max(leftNaturalWidth, leftMinWidth); + leftWidth = Math.max(leftNaturalWidth, leftMinWidth); rightWidth = Math.max(rightNaturalWidth, rightMinWidth); } else { - leftWidth = leftNaturalWidth; + leftWidth = leftNaturalWidth; rightWidth = rightNaturalWidth; } } else if (totalMinWidth < allocWidth) { @@ -3026,18 +2819,18 @@ var Panel = GObject.registerClass({ * Allocate the minWidth and then divide the remaining space * according to how much more they want. */ let totalRemaining = allocWidth - totalMinWidth; - let totalWant = totalNaturalWidth - totalMinWidth; + let totalWant = totalNaturalWidth - totalMinWidth; - leftWidth = leftMinWidth + ((leftNaturalWidth - leftMinWidth) / totalWant) * totalRemaining; + leftWidth = leftMinWidth + ((leftNaturalWidth - leftMinWidth) / totalWant) * totalRemaining; rightWidth = rightMinWidth + ((rightNaturalWidth - rightMinWidth) / totalWant) * totalRemaining; } else { /* Scale everything down according to their minWidth. */ - leftWidth = leftMinWidth / totalMinWidth * allocWidth; + leftWidth = leftMinWidth / totalMinWidth * allocWidth; rightWidth = rightMinWidth / totalMinWidth * allocWidth; } } - leftBoundary = Math.round(leftWidth); + leftBoundary = Math.round(leftWidth); rightBoundary = Math.round(allocWidth - rightWidth); return [leftBoundary, rightBoundary]; @@ -3049,130 +2842,61 @@ var Panel = GObject.registerClass({ const allocWidth = box.x2 - box.x1; const allocHeight = box.y2 - box.y1; - // global.log("panelId " + this.panelId); - // global.log("allocWidth " + allocWidth); - // global.log("allocHeight " + allocHeight); - - // const [, leftNaturalWidth] = this._leftBox.get_preferred_width(-1); - // const [, centerNaturalWidth] = this._centerBox.get_preferred_width(-1); - // const [, rightNaturalWidth] = this._rightBox.get_preferred_width(-1); - - // const centerWidth = centerNaturalWidth; - // const sideWidth = Math.max(0, (allocWidth - centerWidth) / 2); - const childBox = new Clutter.ActorBox(); if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { let [leftBoundary, rightBoundary] = this._calculateBoxes(allocHeight, allocWidth, true); - // global.log("Sizes xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - // global.log("Left Boundary: " + leftBoundary); - // global.log("Right Boundary: " + rightBoundary); - // global.log("Alloc Width: " + allocWidth); - // global.log("Alloc Height: " + allocHeight); - childBox.y1 = 0; - childBox.y2 = leftBoundary; childBox.x1 = 0; childBox.x2 = allocWidth; + + childBox.y1 = 0; + childBox.y2 = leftBoundary; this._leftBox.allocate(childBox, flags); childBox.y1 = leftBoundary; childBox.y2 = rightBoundary; - childBox.x1 = 0; - childBox.x2 = allocWidth; this._centerBox.allocate(childBox, flags); childBox.y1 = rightBoundary; childBox.y2 = allocHeight; - childBox.x1 = 0; - childBox.x2 = allocWidth; this._rightBox.allocate(childBox, flags); } else { let [leftBoundary, rightBoundary] = this._calculateBoxes(allocWidth, allocHeight, false); - // global.log(this.panelId); - // global.log("Sizes xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - // global.log("Left Boundary: " + leftBoundary); - // global.log("Right Boundary: " + rightBoundary); + const isRTL = this.get_direction() === St.TextDirection.RTL; + childBox.y1 = 0; childBox.y2 = allocHeight; - childBox.x1 = 0; - childBox.x2 = leftBoundary; - // childBox.x2 = Math.min(Math.floor(sideWidth), leftNaturalWidth); + + if (isRTL) { + childBox.x1 = leftBoundary; + childBox.x2 = allocWidth; + } else { + childBox.x1 = 0; + childBox.x2 = leftBoundary; + } this._leftBox.allocate(childBox, flags); - childBox.y1 = 0; - childBox.y2 = allocHeight; - // childBox.x1 = Math.ceil(sideWidth); - childBox.x1 = leftBoundary; - // childBox.x2 = childBox.x1 + centerWidth; - childBox.x2 = rightBoundary; + if (isRTL) { + childBox.x1 = rightBoundary; + childBox.x2 = leftBoundary; + } else { + childBox.x1 = leftBoundary; + childBox.x2 = rightBoundary; + } this._centerBox.allocate(childBox, flags); - childBox.y1 = 0; - childBox.y2 = allocHeight; - // childBox.x1 = Math.max(allocWidth - Math.min(Math.floor(sideWidth), rightNaturalWidth), 0); - childBox.x1 = rightBoundary; - childBox.x2 = allocWidth; + if (isRTL) { + childBox.x1 = 0; + childBox.x2 = rightBoundary; + } else { + childBox.x1 = rightBoundary; + childBox.x2 = allocWidth; + } this._rightBox.allocate(childBox, flags); } } - // _allocate(actor, box, flags) { - // // vfunc_allocate(box, flags) { - // // this.set_allocation(box, flags); - - // let allocHeight = box.y2 - box.y1; - // let allocWidth = box.x2 - box.x1; - - // /* Left, center and right panel sections will fit inside this box, which is - // equivalent to the CSS content-box (imaginary box inside borders and paddings) */ - // let childBox = box.copy(); - - // /* The boxes are layout managers, so they rubber-band around their contents and have a few - // characteristics that they enforce on their contents. Of particular note is that the alignment - // - LEFT, CENTER, RIGHT - is not independent of the fill as it probably ought to be, and that there - // is this hybrid FILL alignment that also comes with implied left alignment (probably locale dependent). - // Which is not a great problem when there is something in the box, but if there is nothing in the box and - // something other than FILL alignment is chosen, then the boxes will have no size allocated. - // Which is a bit of a bummer if you need to drag something into an empty box. So we need to work - // around this. That's a manual size set when turning on edit mode, combined with adjustments after drop. - // Note also that settings such as x_fill and y_fill only apply to the children of the box, not to the box itself */ - - // if (this.panelPosition == PanelLoc.left || this.panelPosition == PanelLoc.right) { - - // /* Distribute sizes for the allocated height with points relative to - // the children allocation box, inside borders and paddings. */ - // let [leftBoundary, rightBoundary] = this._calcBoxSizes(allocHeight, allocWidth, true); - // leftBoundary += box.y1; - // rightBoundary += box.y1; - - // this._setVertChildbox (childBox, box.y1, leftBoundary); - // this._leftBox.allocate(childBox, flags); - - // this._setVertChildbox (childBox, leftBoundary, rightBoundary); - // this._centerBox.allocate(childBox, flags); - - // this._setVertChildbox (childBox, rightBoundary, box.y2); - // this._rightBox.allocate(childBox, flags); - // } else { // horizontal panel - - // /* Distribute sizes for the allocated width with points relative to - // the children allocation box, inside borders and paddings. */ - // let [leftBoundary, rightBoundary] = this._calcBoxSizes(allocWidth, allocHeight, false); - // leftBoundary += box.x1; - // rightBoundary += box.x1; - - // this._setHorizChildbox (childBox, box.x1, leftBoundary, leftBoundary, box.x2); - // this._leftBox.allocate(childBox, flags); - - // this._setHorizChildbox (childBox, leftBoundary, rightBoundary, rightBoundary, leftBoundary); - // this._centerBox.allocate(childBox, flags); - - // this._setHorizChildbox (childBox, rightBoundary, box.x2, box.x1, rightBoundary); - // this._rightBox.allocate(childBox, flags); - // } - // } - /** * _panelHasOpenMenus: * @@ -3289,19 +3013,27 @@ var Panel = GObject.registerClass({ * by the coming enter-event, and the panel remains open. */ if (this._shouldShow) { let showDelay = this._getProperty(PANEL_SHOW_DELAY_KEY, "i"); - this._showHideTimer = Mainloop.timeout_add(showDelay, Lang.bind(this, this._showPanel)) + this._showHideTimer = Mainloop.timeout_add(showDelay, this._showPanel.bind(this)); } else { let hideDelay = this._getProperty(PANEL_HIDE_DELAY_KEY, "i"); - this._showHideTimer = Mainloop.timeout_add(hideDelay, Lang.bind(this, this._hidePanel)) + this._showHideTimer = Mainloop.timeout_add(hideDelay, this._hidePanel.bind(this)); } } + vfunc_enter_event() { + this._enterPanel(); + } + _enterPanel(actor=null, event=null) { if (!this._mouseEntered) { this._updatePanelVisibility(); } } + vfunc_leave_event(event) { + this._leavePanel(null, event); + } + _leavePanel(actor=null, event=null) { // Panel gives false leave-event's when mouse is still on panel so we determine this._mouseEntered // manually with this._mouseOnPanel() in this._updatePanelVisibility() @@ -3492,5 +3224,3 @@ var Panel = GObject.registerClass({ this._rightBoxDNDHandler.reset(); } }); - -// Signals.addSignalMethods(Panel.prototype); From aad0f4dda20ada45976e9b71a0a1209a320e1173 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Sat, 28 Feb 2026 16:51:43 -0800 Subject: [PATCH 11/13] panel.js: Clean up a bit of code styling This is only a partial cleanup. This file is a mess of different styles but hopefully it's at least a bit better. --- js/ui/panel.js | 213 +++++++++++++++++++++++++++---------------------- 1 file changed, 117 insertions(+), 96 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 95a5b28851..82fa55710d 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -13,7 +13,7 @@ const GObject = imports.gi.GObject; const Mainloop = imports.mainloop; const Meta = imports.gi.Meta; const Pango = imports.gi.Pango; -const Cinnamon = imports.gi.Cinnamon; // Cinnamon C libraries using GObject Introspection +const Cinnamon = imports.gi.Cinnamon; const St = imports.gi.St; const Gio = imports.gi.Gio; const Gtk = imports.gi.Gtk; @@ -30,7 +30,6 @@ const Util = imports.misc.util; const BUTTON_DND_ACTIVATION_TIMEOUT = 250; -const ANIMATED_ICON_UPDATE_TIMEOUT = 100; const AUTOHIDE_ANIMATION_TIME = 200; const AUTOHIDE_BOX_FADE_TIME = 100; @@ -42,27 +41,36 @@ const EDIT_MODE_MIN_BOX_SIZE = 25; const VALID_ICON_SIZE_VALUES = [-1, 0, 16, 22, 24, 32, 48]; /*** These are defaults for a new panel added */ -const DEFAULT_PANEL_VALUES = {"panels-autohide": "false", - "panels-show-delay": "0", - "panels-hide-delay": "0", - "panels-height": "40"}; - -const DEFAULT_FULLCOLOR_ICON_SIZE_VALUES = {"left": 0, - "center": 0, - "right": 0}; - -const DEFAULT_SYMBOLIC_ICON_SIZE_VALUES = {"left": 28, - "center": 28, - "right": 28}; +const DEFAULT_PANEL_VALUES = { + "panels-autohide": "false", + "panels-show-delay": "0", + "panels-hide-delay": "0", + "panels-height": "40" +}; + +const DEFAULT_FULLCOLOR_ICON_SIZE_VALUES = { + "left": 0, + "center": 0, + "right": 0 +}; + +const DEFAULT_SYMBOLIC_ICON_SIZE_VALUES = { + "left": 28, + "center": 28, + "right": 28 +}; + const MIN_SYMBOLIC_SIZE_PX = 10; const MAX_SYMBOLIC_SIZE_PX = 50; -const DEFAULT_TEXT_SIZE_VALUES = {"left": 0.0, - "center": 0.0, - "right": 0.0}; +const DEFAULT_TEXT_SIZE_VALUES = { + "left": 0.0, + "center": 0.0, + "right": 0.0 +}; + const MIN_TEXT_SIZE_PTS = 6.0; const MAX_TEXT_SIZE_PTS = 16.0; -/*** Defaults ***/ const PANEL_AUTOHIDE_KEY = "panels-autohide"; const PANEL_SHOW_DELAY_KEY = "panels-show-delay"; @@ -149,7 +157,7 @@ function checkPanelUpgrade() * Returns: a two element array */ -function heightsUsedMonitor (monitorIndex, listofpanels) { +function heightsUsedMonitor(monitorIndex, listofpanels) { let toppanelHeight = 0; let bottompanelHeight = 0; @@ -174,8 +182,9 @@ function heightsUsedMonitor (monitorIndex, listofpanels) { * * returns - panel type (integer) */ -function getPanelLocFromName (pname) { - let jj = PanelLoc.bottom; // ensure something credible always returned even if supplied invalid data +function getPanelLocFromName(pname) { + // ensure something credible always returned even if supplied invalid data + let jj = PanelLoc.bottom; switch (pname) { case "bottom": jj = PanelLoc.bottom; @@ -215,10 +224,13 @@ function setHeightForPanel(panel) { let height; // for vertical panels use the width instead of the height - if (panel.panelPosition > 1) height = panel.actor.get_width(); - else height = panel.actor.get_height(); + if (panel.panelPosition > 1) + height = panel.actor.get_width(); + else + height = panel.actor.get_height(); - if (height < 20) height = 40; + if (height < 20) + height = 40; return height; } @@ -241,9 +253,8 @@ function convertSettingsXMonToLMon(strv) { } let l_mon = xmon; - if (!Meta.is_wayland_compositor()) { + if (!Meta.is_wayland_compositor()) l_mon = global.display.xinerama_index_to_logical_index(xmon); - } out.push(`${id}:${l_mon}:${pos}`); @@ -265,9 +276,8 @@ function convertSettingsLMonToXMon(strv) { let [id, lmon, pos] = elements; let x_mon = lmon; - if (!Meta.is_wayland_compositor()) { + if (!Meta.is_wayland_compositor()) x_mon = global.display.logical_index_to_xinerama_index(lmon); - } out.push(`${id}:${x_mon}:${pos}`); @@ -292,7 +302,6 @@ function updatePanelsMeta(meta, panel_props) { // panelMeta is [panel_id][monitor, position] // Find matching panel ids and update their monitor value if necessary. - for (let i = 0; i < meta.length; i++) { if (!meta[i]) continue; @@ -336,7 +345,8 @@ var PanelManager = GObject.registerClass({ this.dummyPanels = []; this.panelCount = 0; this.panels = []; - this.panelsMeta = []; // Properties of panels in format [, ] + // Properties of panels in format [, ] + this.panelsMeta = []; this.canAddPanel = true; this.monitorCount = global.display.get_n_monitors(); @@ -374,13 +384,14 @@ var PanelManager = GObject.registerClass({ */ _fullPanelLoad() { let monitor = 0; - let stash = []; // panel id, monitor, panel type + // panel id, monitor, panel type + let stash = []; let monitorCount = global.display.get_n_monitors(); let panelDefs = getPanelsEnabledList(); - // - // First pass through just to count the monitors, as there is no ordering to rely on - // + + // First pass through just to count the monitors, + // as there is no ordering to rely on let goodDefs = []; let removals = []; for (let i = 0, len = panelDefs.length; i < len; i++) { @@ -429,12 +440,12 @@ var PanelManager = GObject.registerClass({ // set up the list of panels for (let i = 0, len = goodDefs.length; i < len; i++) { let elements = goodDefs[i].split(":"); - - let jj = getPanelLocFromName(elements[PanelDefElement.POSITION]); // panel orientation + // panel orientation + let jj = getPanelLocFromName(elements[PanelDefElement.POSITION]); monitor = parseInt(elements[PanelDefElement.MONITOR]); - - stash[i] = [parseInt(elements[PanelDefElement.ID]), monitor, jj]; // load what we are going to use to call loadPanel into an array + // load what we are going to use to call loadPanel into an array + stash[i] = [parseInt(elements[PanelDefElement.ID]), monitor, jj]; } // When using mixed horizontal and vertical panels draw the vertical panels first. @@ -543,8 +554,9 @@ var PanelManager = GObject.registerClass({ Main.uiGroup.set_child_below_sibling(actor, prev); prev = actor.get_previous_sibling(); continue; - } else + } else { break; + } } } @@ -587,8 +599,8 @@ var PanelManager = GObject.registerClass({ outerLoop: for (let key in DEFAULT_PANEL_VALUES) { let settings = global.settings.get_strv(key); - for (let j = 0; j < settings.length; j++){ - if (settings[j].split(":")[0] == i){ + for (let j = 0; j < settings.length; j++) { + if (settings[j].split(":")[0] == i) { continue outerLoop; } } @@ -615,7 +627,6 @@ var PanelManager = GObject.registerClass({ } setPanelsEnabledList(list); - // Delete all panel dummies if (this.addPanelMode) this._destroyDummyPanels(); } @@ -656,7 +667,6 @@ var PanelManager = GObject.registerClass({ setPanelsEnabledList(list); - // Delete all panel dummies if (this.addPanelMode) this._destroyDummyPanels(); } @@ -763,8 +773,10 @@ var PanelManager = GObject.registerClass({ * Returns (Panel.Panel): Panel created */ _loadPanel(ID, monitorIndex, panelPosition, panelList, metaList) { - if (!panelList) panelList = this.panels; - if (!metaList) metaList = this.panelsMeta; + if (!panelList) + panelList = this.panels; + if (!metaList) + metaList = this.panelsMeta; if (panelList[ID]) { global.log("Multiple panels with same ID (" + ID + ") are found"); @@ -802,9 +814,11 @@ var PanelManager = GObject.registerClass({ } } - if (repeat) return null; + if (repeat) + return null; - metaList[ID] = [monitorIndex, panelPosition]; // Note: metaList [i][0] is the monitor index, metaList [i][1] is the panelPosition + // metaList [i][0] is the monitor index, metaList [i][1] is the panelPosition + metaList[ID] = [monitorIndex, panelPosition]; if (monitorIndex < 0 || monitorIndex >= this.monitorCount) { global.log("Monitor " + monitorIndex + " not found. Not creating panel"); @@ -824,9 +838,8 @@ var PanelManager = GObject.registerClass({ _updateAllPointerBarriers() { for (let i = 0, len = this.panels.length; i < len; i++) { - if (this.panels[i]) { + if (this.panels[i]) this.panels[i]._updatePanelBarriers(); - } } } @@ -839,6 +852,7 @@ var PanelManager = GObject.registerClass({ _onPanelsEnabledChanged() { if (this.handlingPanelsChanged) return; + this.handlingPanelsChanged = true; let newPanels = new Array(this.panels.length); @@ -858,15 +872,16 @@ var PanelManager = GObject.registerClass({ let mon = parseInt(elements[1]); let ploc = getPanelLocFromName(elements[2]); - if (this.panels[ID]) { // If (existing) panel is moved - newMeta[ID] = [mon, ploc]; //Note: meta [i][0] is the monitor meta [i][1] is the panelposition + // If (existing) panel is moved + if (this.panels[ID]) { + newMeta[ID] = [mon, ploc]; - newPanels[ID] = this.panels[ID]; // Move panel object to newPanels - this.panels[ID] = null; // avoids triggering the destroy logic that follows + newPanels[ID] = this.panels[ID]; + this.panels[ID] = null; // avoids triggering the destroy logic that follows delete this.panels[ID]; - if (newMeta[ID][0] != this.panelsMeta[ID][0] || // monitor changed - newMeta[ID][1] != this.panelsMeta[ID][1]) { // or panel position changed + if (newMeta[ID][0] != this.panelsMeta[ID][0] || + newMeta[ID][1] != this.panelsMeta[ID][1]) { newPanels[ID].updatePosition(newMeta[ID][0], newMeta[ID][1]); // Asymmetrical applets such as panel launchers, systray etc. @@ -935,21 +950,20 @@ var PanelManager = GObject.registerClass({ let monitors_changed = updatePanelsMeta(this.panelsMeta, panelProperties) || oldCount !== this.monitorCount; for (let i = 0, len = this.panelsMeta.length; i < len; i++) { - if (!this.panelsMeta[i]) { + if (!this.panelsMeta[i]) continue; - } - - if (!this.panels[i]) { // If there is a meta but not a panel, i.e. panel could not create due to non-existent monitor, try again - // - the monitor may just have been reconnected - if (this.panelsMeta[i][0] < this.monitorCount) // just check that the monitor is there - { + // If there is a meta but not a panel, i.e. panel could not create due to non-existent monitor, try again + // the monitor may have just been reconnected + if (!this.panels[i]) { + if (this.panelsMeta[i][0] < this.monitorCount) { let panel = this._loadPanel(i, this.panelsMeta[i][0], this.panelsMeta[i][1]); if (panel) AppletManager.loadAppletsOnPanel(panel); } - } else if (this.panelsMeta[i][0] >= this.monitorCount) { // Monitor of the panel went missing. Meta is [monitor,panel] array + } else if (this.panelsMeta[i][0] >= this.monitorCount) { if (this.panels[i]) { - this.panels[i].destroy(false); // destroy panel, but don't remove icon size settings + // destroy panel, but don't remove icon size settings + this.panels[i].destroy(false); delete this.panels[i]; this.panelCount -= 1; } @@ -1022,13 +1036,13 @@ var PanelManager = GObject.registerClass({ this.dummyCallback = callback; this.dummyPanels = []; - while (this.dummyPanels.push([true, true, true, true]) < this.monitorCount); // 4 possible panels per monitor + while (this.dummyPanels.push([true, true, true, true]) < this.monitorCount); for (let i = 0, len = this.panelsMeta.length; i < len; i++) { if (!this.panelsMeta[i]) { continue; } - if (this.panelsMeta[i][0] >= this.monitorCount) // Monitor does not exist + if (this.panelsMeta[i][0] >= this.monitorCount) continue; // there is an existing panel showing this.dummyPanels[this.panelsMeta[i][0]][this.panelsMeta[i][1]] = false; @@ -1217,7 +1231,7 @@ var PanelContextMenu = class PanelContextMenu extends PopupMenu.PopupMenu { }; menu.addMenuItem(menu.movePanelItem); - let menuItem = new PopupMenu.PopupIconMenuItem(_("Remove"), "xsi-list-remove", St.IconType.SYMBOLIC); // submenu item remove panel + let menuItem = new PopupMenu.PopupIconMenuItem(_("Remove"), "xsi-list-remove", St.IconType.SYMBOLIC); menuItem.activate = () => { let confirm = new ModalDialog.ConfirmDialog(_("Are you sure you want to remove this panel?"), () => { @@ -1227,7 +1241,7 @@ var PanelContextMenu = class PanelContextMenu extends PopupMenu.PopupMenu { }; menu.addMenuItem(menuItem); - menu.addPanelItem = new PopupMenu.PopupIconMenuItem(_("Add a new panel"), "xsi-list-add", St.IconType.SYMBOLIC); // submenu item add panel + menu.addPanelItem = new PopupMenu.PopupIconMenuItem(_("Add a new panel"), "xsi-list-add", St.IconType.SYMBOLIC); menu.addPanelItem.activate = () => { Main.panelManager.addPanelQuery(); this.close(true); @@ -1339,8 +1353,8 @@ var PanelZoneDNDHandler = class { if (pos != this._dragPlaceholderPos) { this._dragPlaceholderPos = pos; - // Don't allow positioning before or after self + // Don't allow positioning before or after self if (this._origAppletPos != -1 && (pos == this._origAppletPos || pos == this._origAppletPos + 1)) { this._clearDragPlaceholder(); return DND.DragMotionResult.CONTINUE; @@ -1349,7 +1363,6 @@ var PanelZoneDNDHandler = class { // If the placeholder already exists, we just move // it, but if we are adding it, expand its size in // an animation - if (this._dragPlaceholder) { this._panelZone.set_child_at_index(this._dragPlaceholder.actor, this._dragPlaceholderPos); @@ -1426,7 +1439,8 @@ var PanelZoneDNDHandler = class { source.actor._applet._zoneString = this._zoneString; source.actor._applet._newPanelId = this._panelId; - let sourcebox = source.actor._applet._panelLocation; /* this is the panel box providing the applet */ + // this is the panel box providing the applet + let sourcebox = source.actor._applet._panelLocation; this._clearDragPlaceholder(); AppletManager.saveAppletsPositions(); @@ -1646,8 +1660,6 @@ var Panel = GObject.registerClass({ global.log("addContextMenuToPanel - unrecognised panel position "+panelPosition); } this._menus.addMenu(this._context_menu); - - return; } /** @@ -1686,7 +1698,6 @@ var Panel = GObject.registerClass({ default: global.log("addPanelStyleClass - unrecognised panel position "+panelPosition); } - return; } /** @@ -1696,13 +1707,16 @@ var Panel = GObject.registerClass({ * Destroys the panel */ destroy(removeIconSizes = true) { - if (this._destroyed) return; + if (this._destroyed) + return; + this._destroyed = true; // set this early so that any routines triggered during // the destroy process can test it Main.layoutManager.removeChrome(this.actor); - if (removeIconSizes) this._removeZoneIconSizes(); + if (removeIconSizes) + this._removeZoneIconSizes(); // remove icon size settings if requested // settings should be removed except when panel is destroyed due to monitor change // this prevents settings from being reset every time a monitor is disconnected @@ -1780,8 +1794,8 @@ var Panel = GObject.registerClass({ _getProperty(key, type){ let values = global.settings.get_strv(key); let property; - for (let i = 0; i < values.length; i++){ - if (values[i].split(":")[0]==this.panelId){ + for (let i = 0; i < values.length; i++) { + if (values[i].split(":")[0]==this.panelId) { property = values[i].split(":")[1]; break; } @@ -1791,13 +1805,13 @@ var Panel = GObject.registerClass({ values.push(this.panelId + ":" + property); global.settings.set_strv(key, values); } - switch (type){ - case "b": - return property == "true"; - case "i": - return parseInt(property); - default: - return property; + switch (type) { + case "b": + return property == "true"; + case "i": + return parseInt(property); + default: + return property; } } @@ -1871,7 +1885,6 @@ var Panel = GObject.registerClass({ let noBarriers = global.settings.get_boolean("no-adjacent-panel-barriers"); if (this.actor.height && this.actor.width) { - let panelTop = 0; let panelBottom = 0; let panelLeft = 0; @@ -2409,8 +2422,7 @@ var Panel = GObject.registerClass({ if (this.panelPosition == PanelLoc.top || this.panelPosition == PanelLoc.bottom) { this._set_horizontal_panel_style(); this.is_vertical = false; - } - else { + } else { this._set_vertical_panel_style(); this.is_vertical = true; } @@ -2452,7 +2464,8 @@ var Panel = GObject.registerClass({ _setPanelHeight() { let height = setHeightForPanel(this); - if (height === this.heightForZones) return; + if (height === this.heightForZones) + return; this.heightForZones = height; @@ -2479,7 +2492,8 @@ var Panel = GObject.registerClass({ } _onPanelZoneSizesChanged(value, key) { - if (this._destroyed) return; + if (this._destroyed) + return; let changed = false; let oldZoneSizes = this._panelZoneSizes; @@ -2511,7 +2525,8 @@ var Panel = GObject.registerClass({ /* Now, iterate thru the individual set's values (an individual setting key's array of panel sizes), * then compute their display sizes and stick them in this._panelZoneSizes for the current type. */ settingsArray.forEach( sizes => { - if (sizes.panelId !== this.panelId) return; + if (sizes.panelId !== this.panelId) + return; haveSettings = true; @@ -2572,7 +2587,8 @@ var Panel = GObject.registerClass({ } }); - if (changed) this.emit('icon-size-changed'); + if (changed) + this.emit('icon-size-changed'); } _clampPanelZoneTextSize(panelZoneSizeSet, typeString, zoneString, defaults) { @@ -3098,8 +3114,11 @@ var Panel = GObject.registerClass({ _showPanel() { this._showHideTimer = 0; - if (this._disabled) return; - if (!this._hidden) return; + if (this._disabled) + return; + + if (!this._hidden) + return; // setup panel tween - slide in from edge of monitor // if horizontal panel, animation on y. if vertical, animation on x. @@ -3159,10 +3178,12 @@ var Panel = GObject.registerClass({ * This hides the panel. */ _hidePanel() { - if (this._destroyed) return; + if (this._destroyed) + return; this._showHideTimer = 0; - if (this._hidden) return; + if (this._hidden) + return; // setup panel tween - slide out the monitor edge leaving one pixel // if horizontal panel, animation on y. if vertical, animation on x. From f79bd84f365e2e01cde1eb65ba4d62ab303dcf7d Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Sat, 28 Feb 2026 17:31:10 -0800 Subject: [PATCH 12/13] panel.js: Remove unneeded uses of this.actor --- js/ui/panel.js | 142 ++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 82fa55710d..79044941f0 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -1586,9 +1586,9 @@ var Panel = GObject.registerClass({ else this._set_horizontal_panel_style(); - this.actor.add_actor(this._leftBox); - this.actor.add_actor(this._centerBox); - this.actor.add_actor(this._rightBox); + this.add_child(this._leftBox); + this.add_child(this._centerBox); + this.add_child(this._rightBox); this._leftBoxDNDHandler = new PanelZoneDNDHandler(this._leftBox, 'left', this.panelId); this._centerBoxDNDHandler = new PanelZoneDNDHandler(this._centerBox, 'center', this.panelId); @@ -1596,12 +1596,12 @@ var Panel = GObject.registerClass({ this.addContextMenuToPanel(this.panelPosition); - Main.layoutManager.addChrome(this.actor, { addToWindowgroup: false }); + Main.layoutManager.addChrome(this, { addToWindowgroup: false }); this._moveResizePanel(); this._onPanelEditModeChanged(); this._processPanelAutoHide(); - this.actor.connect('queue-relayout', () => this._setPanelHeight()); + this.connect('queue-relayout', () => this._setPanelHeight()); this._signalManager.connect(global.settings, "changed::" + PANEL_AUTOHIDE_KEY, this._processPanelAutoHide, this); this._signalManager.connect(global.settings, "changed::" + PANEL_HEIGHT_KEY, this._moveResizePanel, this); @@ -1672,28 +1672,28 @@ var Panel = GObject.registerClass({ switch (panelPosition) { case PanelLoc.top: - this.actor.remove_style_class_name('panel-bottom'); - this.actor.remove_style_class_name('panel-left'); - this.actor.remove_style_class_name('panel-right'); - this.actor.add_style_class_name('panel-top'); + this.remove_style_class_name('panel-bottom'); + this.remove_style_class_name('panel-left'); + this.remove_style_class_name('panel-right'); + this.add_style_class_name('panel-top'); break; case PanelLoc.bottom: - this.actor.remove_style_class_name('panel-top'); - this.actor.remove_style_class_name('panel-left'); - this.actor.remove_style_class_name('panel-right'); - this.actor.add_style_class_name('panel-bottom'); + this.remove_style_class_name('panel-top'); + this.remove_style_class_name('panel-left'); + this.remove_style_class_name('panel-right'); + this.add_style_class_name('panel-bottom'); break; case PanelLoc.left: - this.actor.remove_style_class_name('panel-bottom'); - this.actor.remove_style_class_name('panel-top'); - this.actor.remove_style_class_name('panel-right'); - this.actor.add_style_class_name('panel-left'); + this.remove_style_class_name('panel-bottom'); + this.remove_style_class_name('panel-top'); + this.remove_style_class_name('panel-right'); + this.add_style_class_name('panel-left'); break; case PanelLoc.right: - this.actor.remove_style_class_name('panel-bottom'); - this.actor.remove_style_class_name('panel-left'); - this.actor.remove_style_class_name('panel-top'); - this.actor.add_style_class_name('panel-right'); + this.remove_style_class_name('panel-bottom'); + this.remove_style_class_name('panel-left'); + this.remove_style_class_name('panel-top'); + this.add_style_class_name('panel-right'); break; default: global.log("addPanelStyleClass - unrecognised panel position "+panelPosition); @@ -1713,7 +1713,7 @@ var Panel = GObject.registerClass({ this._destroyed = true; // set this early so that any routines triggered during // the destroy process can test it - Main.layoutManager.removeChrome(this.actor); + Main.layoutManager.removeChrome(this); if (removeIconSizes) this._removeZoneIconSizes(); @@ -1764,10 +1764,10 @@ var Panel = GObject.registerClass({ * Turns on/off the highlight of the panel */ highlight(highlight) { - if (highlight == this.actor.has_style_pseudo_class('highlight')) + if (highlight == this.has_style_pseudo_class('highlight')) return; - this.actor.change_style_pseudo_class('highlight', highlight); + this.change_style_pseudo_class('highlight', highlight); this._highlighted = highlight; this._updatePanelVisibility(); @@ -1848,10 +1848,10 @@ var Panel = GObject.registerClass({ let leaveIfOut = () => { this._dragShowId = 0; let [x, y, whatever] = global.get_pointer(); - this.actor.sync_hover(); + this.sync_hover(); - if (this.actor.x < x && x < this.actor.x + this.actor.width && - this.actor.y < y && y < this.actor.y + this.actor.height) { + if (this.x < x && x < this.x + this.width && + this.y < y && y < this.y + this.height) { return true; } else { this._leavePanel(); @@ -1884,7 +1884,7 @@ var Panel = GObject.registerClass({ let noBarriers = global.settings.get_boolean("no-adjacent-panel-barriers"); - if (this.actor.height && this.actor.width) { + if (this.height && this.width) { let panelTop = 0; let panelBottom = 0; let panelLeft = 0; @@ -1895,10 +1895,10 @@ var Panel = GObject.registerClass({ switch (this.panelPosition) { case PanelLoc.top: panelTop = this.monitor.y; - panelBottom = this.monitor.y + this.actor.height; + panelBottom = this.monitor.y + this.height; break; case PanelLoc.bottom: - panelTop = this.monitor.y + this.monitor.height - Math.floor(this.actor.height); + panelTop = this.monitor.y + this.monitor.height - Math.floor(this.height); panelBottom = this.monitor.y + this.monitor.height -1; break; } @@ -1928,10 +1928,10 @@ var Panel = GObject.registerClass({ switch (this.panelPosition) { case PanelLoc.left: panelLeft = this.monitor.x; - panelRight = this.monitor.x + Math.floor(this.actor.width); + panelRight = this.monitor.x + Math.floor(this.width); break; case PanelLoc.right: - panelLeft = this.monitor.x + this.monitor.width - Math.floor(this.actor.width); + panelLeft = this.monitor.x + this.monitor.width - Math.floor(this.width); panelRight = this.monitor.x + this.monitor.width-1; break; default: @@ -2108,7 +2108,7 @@ var Panel = GObject.registerClass({ } this._updatePanelVisibility(); - Main.layoutManager._chrome.modifyActorParams(this.actor, { affectsStruts: this._autohideSettings == "false" }); + Main.layoutManager._chrome.modifyActorParams(this, { affectsStruts: this._autohideSettings == "false" }); } /** * _getScaledPanelHeight: @@ -2138,7 +2138,7 @@ var Panel = GObject.registerClass({ _setClipRegion(hidden, offset) { if (!this._shouldClipPanel()) { // important during monitor layout changes. - this.actor.remove_clip(); // no-op if there wasn't any clipping to begin with. + this.remove_clip(); // no-op if there wasn't any clipping to begin with. Main.layoutManager.updateChrome() return; } @@ -2151,18 +2151,18 @@ var Panel = GObject.registerClass({ let exposedAmount; if (isHorizontal) { if (hidden) - exposedAmount = animating ? Math.abs(this.actor.y - offset) + 1 + exposedAmount = animating ? Math.abs(this.y - offset) + 1 : 1; else - exposedAmount = animating ? Math.abs(this.actor.y - offset) - : this.actor.height; + exposedAmount = animating ? Math.abs(this.y - offset) + : this.height; } else { if (hidden) - exposedAmount = animating ? Math.abs(this.actor.x - offset) + 1 + exposedAmount = animating ? Math.abs(this.x - offset) + 1 : 1; else - exposedAmount = animating ? Math.abs(this.actor.x - offset) - : this.actor.width; + exposedAmount = animating ? Math.abs(this.x - offset) + : this.width; } // determine offset & set clip @@ -2177,25 +2177,25 @@ var Panel = GObject.registerClass({ if (isHorizontal) { let clipOffsetY = 0; if (this.panelPosition == PanelLoc.top) { - clipOffsetY = this.actor.height - exposedAmount; + clipOffsetY = this.height - exposedAmount; } else { if (!hidden) clipOffsetY = this._shadowBox.y1; } if (!hidden) exposedAmount += Math.abs(this._shadowBox.y1); - this.actor.set_clip(0, clipOffsetY, this.actor.width, exposedAmount); + this.set_clip(0, clipOffsetY, this.width, exposedAmount); } else { let clipOffsetX = 0; if (this.panelPosition == PanelLoc.left) { - clipOffsetX = this.actor.width - exposedAmount; + clipOffsetX = this.width - exposedAmount; } else { if (!hidden) clipOffsetX = this._shadowBox.x1; } if (!hidden) exposedAmount += Math.abs(this._shadowBox.x1); - this.actor.set_clip(clipOffsetX, 0, exposedAmount, this.actor.height); + this.set_clip(clipOffsetX, 0, exposedAmount, this.height); } // Force the layout manager to update the input region Main.layoutManager.updateChrome() @@ -2219,8 +2219,8 @@ var Panel = GObject.registerClass({ switch (this.panelPosition) { case PanelLoc.top: case PanelLoc.bottom: - test_rect.x = this.actor.x; - test_rect.width = this.actor.width; + test_rect.x = this.x; + test_rect.width = this.width; test_rect.height = this.heightForZones; if (this.panelPosition === PanelLoc.top) { @@ -2231,8 +2231,8 @@ var Panel = GObject.registerClass({ break; case PanelLoc.left: case PanelLoc.right: - test_rect.y = this.actor.y; - test_rect.height = this.actor.height; + test_rect.y = this.y; + test_rect.height = this.height; test_rect.width = this.heightForZones; if (this.panelPosition === PanelLoc.left) { @@ -2286,7 +2286,7 @@ var Panel = GObject.registerClass({ if (Main.panelManager && !horizontal_panel) [this.toppanelHeight, this.bottompanelHeight] = heightsUsedMonitor(this.monitorIndex, Main.panelManager.panels); // get shadow and margins - let themeNode = this.actor.get_theme_node(); + let themeNode = this.get_theme_node(); // FIXME: inset shadows will probably break clipping. // I haven't seen a theme with inset panel shadows, but if there @@ -2350,16 +2350,16 @@ var Panel = GObject.registerClass({ // and determine if this panel's size changed if (horizontal_panel) { - if (this.actor.width != newHorizPanelWidth || this.actor.height != panelHeight) + if (this.width != newHorizPanelWidth || this.height != panelHeight) panelChanged = true; } else { - if (this.actor.width != panelHeight || this.actor.height != newVertPanelHeight) + if (this.width != panelHeight || this.height != newVertPanelHeight) panelChanged = true; } if (panelChanged) { // remove any tweens that might be active for autohide - this.actor.remove_all_transitions(); + this.remove_all_transitions(); this.margin_top = newMarginTop; this.margin_bottom = newMarginBottom; @@ -2377,7 +2377,7 @@ var Panel = GObject.registerClass({ newY = this._hidden ? this.monitor.y + this.monitor.height - 1 : this.monitor.y + this.monitor.height - panelHeight; } - this.actor.set_size(newHorizPanelWidth, panelHeight); + this.set_size(newHorizPanelWidth, panelHeight); } else { newY = this.monitor.y + this.toppanelHeight; if (this.panelPosition == PanelLoc.left) { @@ -2391,7 +2391,7 @@ var Panel = GObject.registerClass({ } // update position and clip region - this.actor.set_position(newX, newY) + this.set_position(newX, newY) this._setClipRegion(this._hidden); // only needed here for when this routine is called when the style changes @@ -2927,7 +2927,7 @@ var Panel = GObject.registerClass({ let menu = global.menuStack[i]; if (menu.customStyleClass && menu.customStyleClass.includes("thumbnail")) continue; - if (menu.getPanel() === this.actor) { + if (menu.getPanel() === this) { return true; } } @@ -2977,19 +2977,19 @@ var Panel = GObject.registerClass({ y = this.monitor.y; break; case PanelLoc.bottom: - y = this.monitor.y + this.monitor.height - this.actor.height; + y = this.monitor.y + this.monitor.height - this.height; break; case PanelLoc.left: x = this.monitor.x; break; case PanelLoc.right: - x = this.monitor.x + this.monitor.width - this.actor.width; + x = this.monitor.x + this.monitor.width - this.width; break; default: global.log("updatePanelVisibility - unrecognised panel position "+this.panelPosition); } - let a = this.actor; + let a = this; let b = global.display.focus_window.get_frame_rect(); /* Magic to check whether the panel position overlaps with the * current focused window */ @@ -3065,11 +3065,11 @@ var Panel = GObject.registerClass({ } _mouseOnPanel() { - this.actor.sync_hover(); + this.sync_hover(); const [x, y] = global.get_pointer(); - return (this.actor.x <= x && x <= this.actor.x + this.actor.width && - this.actor.y <= y && y <= this.actor.y + this.actor.height); + return (this.x <= x && x <= this.x + this.width && + this.y <= y && y <= this.y + this.height); } /** @@ -3080,12 +3080,12 @@ var Panel = GObject.registerClass({ */ disable() { this._disabled = true; - this.actor.ease({ + this.ease({ opacity: 0, duration: AUTOHIDE_ANIMATION_TIME, mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => { - this.actor.hide(); + this.hide(); } }); } @@ -3097,8 +3097,8 @@ var Panel = GObject.registerClass({ */ enable() { this._disabled = false; - this.actor.show(); - this.actor.ease({ + this.show(); + this.ease({ opacity: 255, duration: AUTOHIDE_ANIMATION_TIME, mode: Clutter.AnimationMode.EASE_OUT_QUAD @@ -3132,7 +3132,7 @@ var Panel = GObject.registerClass({ // destination parameter let origPos, destPos; if (isHorizontal) { - let height = this.actor.get_height(); + let height = this.get_height(); if (this.panelPosition == PanelLoc.top) { destPos = this.monitor.y; origPos = this.monitor.y - height; @@ -3142,7 +3142,7 @@ var Panel = GObject.registerClass({ } panelParams['y'] = destPos; } else { - let width = this.actor.get_width(); + let width = this.get_width(); if (this.panelPosition == PanelLoc.left) { destPos = this.monitor.x; origPos = this.monitor.x - width; @@ -3164,7 +3164,7 @@ var Panel = GObject.registerClass({ this._leftBox.show(); this._centerBox.show(); this._rightBox.show(); - this.actor.ease(panelParams); + this.ease(panelParams); this._leftBox.ease(boxParams); this._centerBox.ease(boxParams); this._rightBox.ease(boxParams); @@ -3197,14 +3197,14 @@ var Panel = GObject.registerClass({ // will become inaccessible let destPos; if (isHorizontal) { - let height = this.actor.get_height(); + let height = this.get_height(); if (this.panelPosition == PanelLoc.top) destPos = this.monitor.y - height + 1; else destPos = this.monitor.y + this.monitor.height - 1; panelParams['y'] = destPos; } else { - let width = this.actor.get_width(); + let width = this.get_width(); if (this.panelPosition == PanelLoc.left) destPos = this.monitor.x - width + 1; else @@ -3227,7 +3227,7 @@ var Panel = GObject.registerClass({ mode: Clutter.AnimationMode.EASE_OUT_QUAD }; // add all tweens - this.actor.ease(panelParams); + this.ease(panelParams); this._leftBox.ease(boxParams); this._centerBox.ease(boxParams); this._rightBox.ease(boxParams); From 6457f02cbd95949da01c5deb40dbe5a0f8ea70b7 Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Tue, 3 Mar 2026 17:40:38 -0800 Subject: [PATCH 13/13] appletManager.js: Fixed a typo in variable name Missed this when converting the panel to an St.Widget --- js/ui/appletManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/ui/appletManager.js b/js/ui/appletManager.js index b038e05ac4..770ab34b39 100644 --- a/js/ui/appletManager.js +++ b/js/ui/appletManager.js @@ -597,7 +597,7 @@ function createApplet(extension, appletDefinition, panel = null) { // FIXME: Panel height is now available before an applet is initialized, // so we don't need to pass it to the constructor anymore, but would // require a compatibility clean-up effort. - applet = extension.module.main(extension.meta, orientation, panel.heightForZone, applet_id); + applet = extension.module.main(extension.meta, orientation, panel.heightForZones, applet_id); } catch (e) { Extension.logError(`Failed to evaluate 'main' function on applet: ${uuid}/${applet_id}`, uuid, e); return null;