From e79d0da8c9856764e32e9cab7cd6a1802677650e Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 12 May 2020 19:00:51 -0400 Subject: [PATCH 01/21] Add new panel positioning options --- Makefile | 2 +- Settings.ui | 468 ++++-------------- .../sources/D2P_import settings/Artist_design | 2 - .../D2P_import settings/Fortnite_Brite gunner | 2 - .../D2P_import settings/Galaxy_bizouneur | 2 - .../D2P_import settings/Ghibli_student | 2 - .../D2P_import settings/Mountain_intellihide | 3 - .../D2P_import settings/Plants_Solitaire | 2 - .../D2P_import settings/Star Wars_gamer | 2 - .../D2P_import settings/Wolf_programmer | 3 - panel.js | 429 +++++++++------- panelManager.js | 27 +- panelPositions.js | 60 +++ panelStyle.js | 50 +- prefs.js | 440 ++++++++-------- ...shell.extensions.dash-to-panel.gschema.xml | 49 +- stylesheet.css | 2 +- taskbar.js | 29 +- 18 files changed, 696 insertions(+), 878 deletions(-) create mode 100644 panelPositions.js diff --git a/Makefile b/Makefile index 23278d0..334f60f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UUID = dash-to-panel@jderose9.github.com BASE_MODULES = extension.js stylesheet.css metadata.json COPYING README.md -EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui +EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui EXTRA_IMAGES = highlight_stacked_bg.svg highlight_stacked_bg_2.svg highlight_stacked_bg_3.svg TOLOCALIZE = prefs.js appIcons.js update.js diff --git a/Settings.ui b/Settings.ui index 8949c9f..118d7f4 100644 --- a/Settings.ui +++ b/Settings.ui @@ -3782,6 +3782,54 @@ 2 + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Animate <i>Show Applications</i>. + True + 0 + + + 0 + 0 + + + + + True + True + end + center + + + 1 + 0 + + + + + + + False + True + 3 + + 5000 @@ -4394,94 +4442,61 @@ 0 in - + True False - none + vertical - - 100 + True - True + False + 12 + 12 + 12 + 12 - + True False - 12 - 12 - 12 - 12 - 32 - 32 - - - True - False - True - Taskbar position - 0 - - - 0 - 0 - - - - - True - False - center - - - 1 - 0 - - + True + Order and position of panel elements on monitor + 0 + + 0 + 0 + + + + + True + False + center + + + 1 + 0 + + + False + True + 0 + - + True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - 32 - - - True - False - True - Clock location - 0 - - - 0 - 0 - - - - - True - False - center - - - 1 - 0 - - - - + False + 6 + none + + False + True + 1 + @@ -4588,79 +4603,6 @@ 0 - - - True - False - True - True - 0 - - - 0 - 3 - - - - - True - False - True - True - 0 - - - 0 - 2 - - - - - True - True - end - center - - - 1 - 3 - - - - - True - True - end - center - - - 1 - 2 - - - - - True - False - True - 6 - True - For the following 2 options, "additional" refers to panels that are displayed in addition to the gnome-shell top panel. - True - 40 - 0 - - - - 0 - 1 - - - - - @@ -5847,238 +5789,6 @@ - - - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Show <i>Applications</i> icon - True - 0 - - - 0 - 0 - - - - - True - True - False - 12 - 3 - 0 - 0.5 - True - - - 4 - True - False - 4 - Animate <i>Show Applications</i>. - True - - - - - 0 - 1 - 2 - - - - - True - False - 6 - - - True - True - True - center - center - 0.46000000834465027 - - - True - False - emblem-system-symbolic - - - - - - False - True - 0 - - - - - True - True - end - center - - - False - True - 1 - - - - - 1 - 0 - - - - - - - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - True - end - center - - - 1 - 0 - - - - - True - False - True - Show <i>Activities</i> button - True - 0 - - - 0 - 0 - - - - - - - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Show <i>Desktop</i> button - True - 0 - - - 0 - 0 - - - - - True - False - 6 - - - True - True - True - center - center - 0.46000000834465027 - - - True - False - emblem-system-symbolic - - - - - - False - True - 0 - - - - - True - True - end - center - - - False - True - 1 - - - - - 1 - 0 - - - - - - 100 diff --git a/media/sources/D2P_import settings/Artist_design b/media/sources/D2P_import settings/Artist_design index a744408..3390515 100644 --- a/media/sources/D2P_import settings/Artist_design +++ b/media/sources/D2P_import settings/Artist_design @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='BUTTONSRIGHT' panel-position='BOTTOM' hot-keys=true window-preview-height=50 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='DOTS' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#2195c5' -taskbar-position='LEFTPANEL_FIXEDCENTER' click-action='MINIMIZE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Fortnite_Brite gunner b/media/sources/D2P_import settings/Fortnite_Brite gunner index 75f5744..74a20b7 100644 --- a/media/sources/D2P_import settings/Fortnite_Brite gunner +++ b/media/sources/D2P_import settings/Fortnite_Brite gunner @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSLEFT' panel-position='BOTTOM' hot-keys=true window-preview-height=50 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='CILIORA' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#765550' -taskbar-position='CENTEREDMONITOR' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Galaxy_bizouneur b/media/sources/D2P_import settings/Galaxy_bizouneur index 17d52d8..61385c2 100644 --- a/media/sources/D2P_import settings/Galaxy_bizouneur +++ b/media/sources/D2P_import settings/Galaxy_bizouneur @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSLEFT' panel-position='TOP' hot-keys=true window-preview-height=100 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='CILIORA' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#4a5b8f' -taskbar-position='LEFTPANEL' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Ghibli_student b/media/sources/D2P_import settings/Ghibli_student index 1bcefa0..6f38506 100644 --- a/media/sources/D2P_import settings/Ghibli_student +++ b/media/sources/D2P_import settings/Ghibli_student @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSRIGHT' panel-position='TOP' hot-keys=true window-preview-height=80 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='DOTS' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#2195c5' -taskbar-position='CENTEREDMONITOR' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Mountain_intellihide b/media/sources/D2P_import settings/Mountain_intellihide index 8b46192..de05575 100644 --- a/media/sources/D2P_import settings/Mountain_intellihide +++ b/media/sources/D2P_import settings/Mountain_intellihide @@ -45,7 +45,6 @@ app-hotkey-6=['6'] app-hotkey-7=['7'] app-hotkey-8=['8'] app-hotkey-9=['9'] -location-clock='STATUSLEFT' intellihide-use-pressure=false intellihide-pressure-time=1000 app-ctrl-hotkey-10=['0'] @@ -103,7 +102,6 @@ show-apps-icon-file='' primary-monitor=0 window-preview-width=240 trans-gradient-top-opacity=0.0 -show-clock-all-monitors=true intellihide-close-delay=400 focus-highlight=true app-hotkey-10=['0'] @@ -164,7 +162,6 @@ leftbox-size=0 group-apps-label-font-weight='inherit' appicon-padding=2 trans-dynamic-opacity=true -taskbar-position='LEFTPANEL' intellihide-animation-time=200 hot-keys=false app-hotkey-kp-10=['KP_0'] diff --git a/media/sources/D2P_import settings/Plants_Solitaire b/media/sources/D2P_import settings/Plants_Solitaire index a4c0ae7..7b6aae4 100644 --- a/media/sources/D2P_import settings/Plants_Solitaire +++ b/media/sources/D2P_import settings/Plants_Solitaire @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='BUTTONSRIGHT' panel-position='TOP' hot-keys=true window-preview-height=50 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='SEGMENTED' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#e5e3e4' -taskbar-position='LEFTPANEL_FIXEDCENTER' click-action='MINIMIZE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Star Wars_gamer b/media/sources/D2P_import settings/Star Wars_gamer index 325622f..74d2577 100644 --- a/media/sources/D2P_import settings/Star Wars_gamer +++ b/media/sources/D2P_import settings/Star Wars_gamer @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSLEFT' panel-position='BOTTOM' hot-keys=true window-preview-height=100 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='DASHES' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#3b5346' -taskbar-position='LEFTPANEL_FLOATCENTER' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Wolf_programmer b/media/sources/D2P_import settings/Wolf_programmer index 3bfa1f8..167b75a 100644 --- a/media/sources/D2P_import settings/Wolf_programmer +++ b/media/sources/D2P_import settings/Wolf_programmer @@ -45,7 +45,6 @@ app-hotkey-6=['6'] app-hotkey-7=['7'] app-hotkey-8=['8'] app-hotkey-9=['9'] -location-clock='STATUSLEFT' intellihide-use-pressure=false intellihide-pressure-time=1000 app-ctrl-hotkey-10=['0'] @@ -103,7 +102,6 @@ show-apps-icon-file='' primary-monitor=0 window-preview-width=240 trans-gradient-top-opacity=0.0 -show-clock-all-monitors=true intellihide-close-delay=400 focus-highlight=true app-hotkey-10=['0'] @@ -163,7 +161,6 @@ leftbox-size=0 group-apps-label-font-weight='inherit' appicon-padding=2 trans-dynamic-opacity=true -taskbar-position='LEFTPANEL' intellihide-animation-time=200 hot-keys=false app-hotkey-kp-10=['KP_0'] diff --git a/panel.js b/panel.js index 5ded78e..70307c3 100644 --- a/panel.js +++ b/panel.js @@ -35,6 +35,7 @@ const Gi = imports._gi; const AppIcons = Me.imports.appIcons; const Utils = Me.imports.utils; const Taskbar = Me.imports.taskbar; +const Pos = Me.imports.panelPositions; const PanelStyle = Me.imports.panelStyle; const Lang = imports.lang; const Main = imports.ui.main; @@ -167,9 +168,9 @@ var dtpPanel = Utils.defineClass({ this.menuManager = this.panel.menuManager = new PopupMenu.PopupMenuManager(this.panel); - //adding the clock to the centerbox will correctly position it according to dtp settings (event actor-added) - this._setPanelMenu('show-status-menu-all-monitors', 'aggregateMenu', dtpSecondaryAggregateMenu, this._rightBox, true); - this._setPanelMenu('show-clock-all-monitors', 'dateMenu', DateMenu.DateMenuButton, this._centerBox, true); + this._setPanelMenu('aggregateMenu', dtpSecondaryAggregateMenu, this.panel.actor); + this._setPanelMenu('dateMenu', DateMenu.DateMenuButton, this.panel.actor); + this._setPanelMenu('activities', Panel.ActivitiesButton, this.panel.actor); if (this.statusArea.aggregateMenu) { setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), position); @@ -186,24 +187,39 @@ var dtpPanel = Utils.defineClass({ setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), position); panelBoxes.forEach(p => this[p] = Main.panel[p]); + + this._leftBox.remove_child(this.statusArea.activities.container); + this.panel.actor.add_child(this.statusArea.activities.container); + + this._rightBox.remove_child(this.statusArea.aggregateMenu.container); + this.panel.actor.add_child(this.statusArea.aggregateMenu.container); + + this._centerBox.remove_child(this.statusArea.dateMenu.container); + this.panel.actor.add_child(this.statusArea.dateMenu.container); } + // Create a wrapper around the real showAppsIcon in order to add a popupMenu. Most of + // its behavior is handled by the taskbar, but its positioning is done at the panel level + this.showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(); + this.showAppsIconWrapper._dtpPanel = this; + this.panel.actor.add_child(this.showAppsIconWrapper.realShowAppsIcon); + this.panel.actor._delegate = this; if (position == St.Side.TOP) { this.panel._leftCorner = this.panel._leftCorner || new Panel.PanelCorner(St.Side.LEFT); this.panel._rightCorner = this.panel._rightCorner || new Panel.PanelCorner(St.Side.RIGHT); - - if (isStandalone) { - this.panel.add_child(this.panel._leftCorner.actor); - this.panel.add_child(this.panel._rightCorner.actor); - this.panel._rightCorner.setStyleParent(this._rightBox); - } } Utils.wrapActor(this.panel._leftCorner || 0); Utils.wrapActor(this.panel._rightCorner || 0); + if (isStandalone && position == St.Side.TOP) { + this.panel.actor.add_child(this.panel._leftCorner.actor); + this.panel.actor.add_child(this.panel._rightCorner.actor); + this.panel._rightCorner.setStyleParent(this.panel.actor); + } + this.add_child(this.panel.actor); if (Main.panel._onButtonPress || Main.panel._tryDragWindow) { @@ -226,15 +242,8 @@ var dtpPanel = Utils.defineClass({ }, enable : function() { - let taskbarPosition = Me.settings.get_string('taskbar-position'); let position = getPosition(); - if (taskbarPosition == 'CENTEREDCONTENT' || taskbarPosition == 'CENTEREDMONITOR') { - this.container = this._centerBox; - } else { - this.container = this._leftBox; - } - if (this.statusArea.aggregateMenu) { Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll = 1; } @@ -322,13 +331,13 @@ var dtpPanel = Utils.defineClass({ this.taskbar = new Taskbar.taskbar(this); - this.container.insert_child_above(this.taskbar.actor, null); - - this._setActivitiesButtonVisible(Me.settings.get_boolean('show-activities-button')); + this.panel.actor.add_child(this.taskbar.actor); + this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')); - this._setClockLocation(Me.settings.get_string('location-clock')); - this._displayShowDesktopButton(Me.settings.get_boolean('show-showdesktop-button')); + this._setShowDesktopButton(true); + this._setAllocationMap(); + this._setRightCornerStyle(); this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + getOrientation()); @@ -340,9 +349,6 @@ var dtpPanel = Utils.defineClass({ this._setPanelGhostSize(); - if(this.taskbar._showAppsIconWrapper) - this.taskbar._showAppsIconWrapper._dtpPanel = this; - this._timeoutsHandler.add([T2, Me.settings.get_int('intellihide-enable-start-delay'), () => this.intellihide = new Intellihide.Intellihide(this)]); this._signalsHandler.add( @@ -356,7 +362,7 @@ var dtpPanel = Utils.defineClass({ // sync hover after a popupmenu is closed this.taskbar, 'menu-closed', - Lang.bind(this, function(){this.container.sync_hover();}) + Lang.bind(this, function(){this.panel.actor.sync_hover();}) ], [ Main.overview, @@ -429,7 +435,7 @@ var dtpPanel = Utils.defineClass({ this._timeoutsHandler.destroy(); this._signalsHandler.destroy(); - this.container.remove_child(this.taskbar.actor); + this.panel.remove_child(this.taskbar.actor); this._setAppmenuVisible(false); if (this.intellihide) { @@ -441,6 +447,7 @@ var dtpPanel = Utils.defineClass({ this.progressManager.destroy(); this.taskbar.destroy(); + this.showAppsIconWrapper.destroy(); this.menuManager._changeMenu = this.menuManager._oldChangeMenu; @@ -463,10 +470,16 @@ var dtpPanel = Utils.defineClass({ ['vertical', 'horizontal', 'dashtopanelMainPanel'].forEach(c => this.panel.actor.remove_style_class_name(c)); - if(!Main.sessionMode.isLocked) { - this._setActivitiesButtonVisible(true); - this._setClockLocation("BUTTONSLEFT"); + if (!Main.sessionMode.isLocked) { + this.panel.remove_child(this.statusArea.activities.container); + this._leftBox.insert_child_at_index(this.statusArea.activities.container, 0); + this.panel.remove_child(this.statusArea.dateMenu.container); + this._centerBox.insert_child_at_index(this.statusArea.dateMenu.container, 0); + + this.panel.remove_child(this.statusArea.aggregateMenu.container); + this._rightBox.add_child(this.statusArea.aggregateMenu.container); + if (this.statusArea.appMenu) { setMenuArrow(this.statusArea.appMenu._arrow, St.Side.TOP); this._leftBox.add_child(this.statusArea.appMenu.container); @@ -477,7 +490,7 @@ var dtpPanel = Utils.defineClass({ } } - this._displayShowDesktopButton(false); + this._setShowDesktopButton(false); this._toggleCornerStyle(this.panel._leftCorner, true); this._toggleCornerStyle(this.panel._rightCorner, true); @@ -500,6 +513,7 @@ var dtpPanel = Utils.defineClass({ } else { this._removePanelMenu('dateMenu'); this._removePanelMenu('aggregateMenu'); + this._removePanelMenu('activities'); if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); @@ -521,6 +535,23 @@ var dtpPanel = Utils.defineClass({ return DND.DragMotionResult.CONTINUE; }, + updateElementPositions: function() { + this._getElementPositions().forEach(pos => { + let actor = this.allocationMap[pos.element].actor; + + if (actor) { + actor.visible = pos.visible; + } + }); + + this.panel.actor.hide(); + this.panel.actor.show(); + }, + + _getElementPositions: function() { + return this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; + }, + _bindSettingsChanges: function() { let isVertical = checkIfVertical(); @@ -541,26 +572,11 @@ var dtpPanel = Utils.defineClass({ ], () => this.taskbar.resetAppIcons() ], - [ - Me.settings, - 'changed::show-activities-button', - () => this._setActivitiesButtonVisible(Me.settings.get_boolean('show-activities-button')) - ], [ Me.settings, 'changed::show-appmenu', () => this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')) ], - [ - Me.settings, - 'changed::location-clock', - () => this._setClockLocation(Me.settings.get_string('location-clock')) - ], - [ - Me.settings, - 'changed::show-showdesktop-button', - () => this._displayShowDesktopButton(Me.settings.get_boolean('show-showdesktop-button')) - ], [ Me.settings, 'changed::showdesktop-button-width', @@ -594,14 +610,8 @@ var dtpPanel = Utils.defineClass({ } }, - _setPanelMenu: function(settingName, propName, constr, container, isInit) { - if (isInit) { - this._signalsHandler.add([Me.settings, 'changed::' + settingName, () => this._setPanelMenu(settingName, propName, constr, container)]); - } - - if (!Me.settings.get_boolean(settingName)) { - this._removePanelMenu(propName); - } else if (!this.statusArea[propName]) { + _setPanelMenu: function(propName, constr, container) { + if (!this.statusArea[propName]) { this.statusArea[propName] = this._getPanelMenu(propName, constr); this.menuManager.addMenu(this.statusArea[propName].menu); container.insert_child_at_index(this.statusArea[propName].container, 0); @@ -679,7 +689,7 @@ var dtpPanel = Utils.defineClass({ this.geom = this.getGeometry(); this._setPanelGhostSize(); this._setPanelPosition(); - this.taskbar.resetAppIcons(); + this.taskbar.resetAppIcons(true); this.dynamicTransparency.updateExternalStyle(); if (this.intellihide && this.intellihide.enabled) { @@ -687,6 +697,7 @@ var dtpPanel = Utils.defineClass({ } if (checkIfVertical()) { + this.showAppsButton.set_width(this.geom.w); this._refreshVerticalAlloc(); this._setSearchEntryOffset(this.geom.w); } @@ -750,91 +761,188 @@ var dtpPanel = Utils.defineClass({ }; }, + _setAllocationMap: function() { + this.allocationMap = {}; + let setMap = (name, actor, isBox) => this.allocationMap[name] = { + actor: actor, + isBox: isBox || 0, + box: new Clutter.ActorBox() + }; + + setMap(Pos.SHOW_APPS_BTN, this.showAppsIconWrapper.realShowAppsIcon); + setMap(Pos.ACTIVITIES_BTN, this.statusArea.activities ? this.statusArea.activities.container : 0); + setMap(Pos.LEFT_BOX, this._leftBox, 1); + setMap(Pos.TASKBAR, this.taskbar.actor); + setMap(Pos.CENTER_BOX, this._centerBox, 1); + setMap(Pos.DATE_MENU, this.statusArea.dateMenu.container); + setMap(Pos.SYSTEM_MENU, this.statusArea.aggregateMenu.container); + setMap(Pos.RIGHT_BOX, this._rightBox, 1); + setMap(Pos.DESKTOP_BTN, this._showDesktopButton); + }, + _mainPanelAllocate: function(actor, box, flags) { this.panel.actor.set_allocation(box, flags); }, vfunc_allocate: function(box, flags) { this.set_allocation(box, flags); - - let panelAllocVarSize = box[varCoord.c2] - box[varCoord.c1]; - let panelAllocFixedSize = box[fixedCoord.c2] - box[fixedCoord.c1]; - let [, leftNaturalSize] = this._leftBox[sizeFunc](-1); - let [, centerNaturalSize] = this._centerBox[sizeFunc](-1); - let [, rightNaturalSize] = this._rightBox[sizeFunc](-1); - let taskbarPosition = Me.settings.get_string('taskbar-position'); - - // The _rightBox is always allocated the same, regardless of taskbar position setting - let rightAllocSize = rightNaturalSize; - - // Now figure out how large the _leftBox and _centerBox should be. - // The box with the taskbar is always the one that is forced to be smaller as the other boxes grow - let leftAllocSize, centerStartPosition, centerEndPosition; - let childBoxLeft = new Clutter.ActorBox(); - let childBoxCenter = new Clutter.ActorBox(); - let childBoxRight = new Clutter.ActorBox(); - - if (taskbarPosition == 'CENTEREDMONITOR') { - leftAllocSize = leftNaturalSize; - - centerStartPosition = Math.max(leftNaturalSize, Math.floor((panelAllocVarSize - centerNaturalSize)/2)); - centerEndPosition = Math.min(panelAllocVarSize-rightNaturalSize, Math.ceil((panelAllocVarSize+centerNaturalSize))/2); - } else if (taskbarPosition == 'CENTEREDCONTENT') { - leftAllocSize = leftNaturalSize; - - centerStartPosition = Math.max(leftNaturalSize, Math.floor((panelAllocVarSize - centerNaturalSize + leftNaturalSize - rightNaturalSize) / 2)); - centerEndPosition = Math.min(panelAllocVarSize-rightNaturalSize, Math.ceil((panelAllocVarSize + centerNaturalSize + leftNaturalSize - rightNaturalSize) / 2)); - } else if (taskbarPosition == 'LEFTPANEL_FIXEDCENTER') { - leftAllocSize = Math.floor((panelAllocVarSize - centerNaturalSize) / 2); - centerStartPosition = leftAllocSize; - centerEndPosition = centerStartPosition + centerNaturalSize; - } else if (taskbarPosition == 'LEFTPANEL_FLOATCENTER') { - let leftAllocSizeMax = panelAllocVarSize - rightNaturalSize - centerNaturalSize; - leftAllocSize = Math.min(leftAllocSizeMax, leftNaturalSize); - - let freeSpace = panelAllocVarSize - leftAllocSize - rightAllocSize - centerNaturalSize; - - centerStartPosition = leftAllocSize + Math.floor(freeSpace / 2); - centerEndPosition = centerStartPosition + centerNaturalSize; - } else { // LEFTPANEL - leftAllocSize = panelAllocVarSize - rightNaturalSize - centerNaturalSize; - centerStartPosition = leftAllocSize; - centerEndPosition = centerStartPosition + centerNaturalSize; - } - - childBoxLeft[fixedCoord.c1] = childBoxCenter[fixedCoord.c1] = childBoxRight[fixedCoord.c1] = 0; - childBoxLeft[fixedCoord.c2] = childBoxCenter[fixedCoord.c2] = childBoxRight[fixedCoord.c2] = panelAllocFixedSize; - - // if it is a RTL language, the boxes are switched around, and we need to invert the coordinates - if (this.get_text_direction() == Clutter.TextDirection.RTL) { - childBoxLeft[varCoord.c1] = panelAllocVarSize - leftAllocSize; - childBoxLeft[varCoord.c2] = panelAllocVarSize; - - childBoxCenter[varCoord.c1] = panelAllocVarSize - centerEndPosition; - childBoxCenter[varCoord.c2] = panelAllocVarSize - centerStartPosition; - - childBoxRight[varCoord.c1] = 0; - childBoxRight[varCoord.c2] = rightAllocSize; - } else { - childBoxLeft[varCoord.c1] = 0; - childBoxLeft[varCoord.c2] = leftAllocSize; - - childBoxCenter[varCoord.c1] = centerStartPosition; - childBoxCenter[varCoord.c2] = centerEndPosition; - - childBoxRight[varCoord.c1] = panelAllocVarSize - rightAllocSize; - childBoxRight[varCoord.c2] = panelAllocVarSize; - } this.panel.actor.allocate(new Clutter.ActorBox({ x1: 0, y1: 0, x2: this.geom.w, y2: this.geom.h }), flags); - this._leftBox.allocate(childBoxLeft, flags, 1); - this._centerBox.allocate(childBoxCenter, flags, 1); - this._rightBox.allocate(childBoxRight, flags, 1); + + let panelAllocVarSize = box[varCoord.c2] - box[varCoord.c1]; + let elements = []; + let centerMonitorElements = []; + let fixed = 0; + let checkIfCentered = element => element.position == Pos.CENTERED || element.position == Pos.CENTERED_MONITOR; + let allocateCenter = (centeredElements, trLimit, brLimit) => { + if (centeredElements.length) { + centeredElements.filter(c => c.hasDynamicSize).forEach(c => adjustDynamicSize(c)); + + let centeredWidth = centeredElements.reduce((size, c) => size + c.natSize, 0); + let tlOffset = Math.max(0, Math.round((brLimit - trLimit - centeredWidth) * .5)); + + centeredElements.forEach(c => { + allocate(c, trLimit + tlOffset); + trLimit += c.natSize; + }); + } + }; + let allocate = (element, c1) => { + element.box[varCoord.c1] = Math.max(0, Math.min(panelAllocVarSize, c1)); + element.box[varCoord.c2] = Math.max(element.natSize, Math.min(panelAllocVarSize, element.box[varCoord.c1] + element.natSize)); + + if (element.hasDynamicSize) { + adjustDynamicSize(element, true); + } + + element.fixed = 1; + ++fixed; + + let params = [element.box, flags]; + + if (element.isBox) { + params.push(1); + } + + element.actor.allocate.apply(element.actor, params); + }; + let adjustDynamicSize = (element, adjustPos) => { + let isCentered = checkIfCentered(element); + let getSiblingsInfo = (direction, defaultLimit = 0, unfixedSize = 0, centeredSize = 0, limit = 0) => { + let j = element.index + direction; + let refElement = elements[j]; + + while (refElement && (!refElement.fixed || (isCentered && refElement.position == element.position))) { + if (isCentered && refElement.position == element.position) { + centeredSize += refElement.natSize; + } + + unfixedSize += refElement.natSize; + refElement = elements[(j += direction)]; + } + + limit = refElement ? refElement.box[varCoord[direction > 0 ? 'c1' : 'c2']] : defaultLimit; + + return [unfixedSize, centeredSize, limit]; + }; + let [unfixedSizeTl, centeredSizeTl, prevLimit] = getSiblingsInfo(-1); + let [unfixedSizeBr, centeredSizeBr, nextLimit] = getSiblingsInfo(1, panelAllocVarSize); + let availableSize = nextLimit - prevLimit - unfixedSizeTl - unfixedSizeBr - + (isCentered ? Math.abs((unfixedSizeTl - centeredSizeTl) - (unfixedSizeBr - centeredSizeBr)) : 0); + + if (availableSize < element.natSize) { + element.natSize = availableSize; + + if (adjustPos) { + element.box[varCoord.c1] = Math.max(prevLimit + unfixedSizeTl, element.box[varCoord.c1]); + element.box[varCoord.c2] = Math.min(nextLimit - unfixedSizeBr, element.box[varCoord.c2]); + } + } + + element.hasDynamicSize = 0; + }; + + this._getElementPositions().forEach(pos => { + let element = this.allocationMap[pos.element]; + + if (element.actor && pos.visible) { + element.natSize = element.actor[sizeFunc](-1)[1]; + + if (element.natSize <= 0) return; + + element.box[fixedCoord.c1] = box[fixedCoord.c1]; + element.box[fixedCoord.c2] = box[fixedCoord.c2]; + element.hasDynamicSize = pos.element == Pos.TASKBAR; + element.index = elements.length; + element.position = pos.position; + element.fixed = 0; + + if (pos.position == Pos.CENTERED_MONITOR && + (!centerMonitorElements.length || elements[element.index - 1].position == Pos.CENTERED_MONITOR)) { + centerMonitorElements.push(element); + } + + elements.push(element); + } + }); + + allocateCenter(centerMonitorElements, 0, box[varCoord.c2]); + + let iterations = 0; //failsafe + while (fixed < elements.length && ++iterations < 10) { + for (let i = 0, l = elements.length; i < l; ++i) { + if (elements[i].fixed) continue; + + let element = elements[i]; + let prevElement = elements[i - 1]; + let nextElement = elements[i + 1]; + + if (element.position == Pos.STACKED_TL && prevElement && prevElement.position == Pos.STACKED_BR) { + element.position = Pos.STACKED_BR; + } + + if (element.position == Pos.STACKED_TL && (!prevElement || prevElement.fixed)) { + allocate(element, prevElement ? prevElement.box[varCoord.c2] : 0); + } else if (element.position == Pos.STACKED_BR && (!nextElement || nextElement.fixed)) { + let nextLimit = nextElement ? nextElement.box[varCoord.c1] : panelAllocVarSize; + + allocate(element, nextLimit - element.natSize); + } else if (checkIfCentered(element)) { //fallback for non contiguous CENTERED_MONITOR + let centeredElements = [element]; + let j = i; + + while (prevElement && prevElement.position == Pos.STACKED_BR) { + prevElement = elements[--j]; + } + + if (prevElement && !prevElement.fixed) continue; + + while (nextElement && checkIfCentered(nextElement)) { + centeredElements.push(nextElement); + nextElement = elements[++i + 1]; + } + + j = i; + while (nextElement && nextElement.position == Pos.STACKED_TL) { + nextElement = elements[++j]; + } + + if (!nextElement || (nextElement.fixed)) { + allocateCenter( + centeredElements, + prevElement ? prevElement.box[varCoord.c2] : 0, + nextElement ? nextElement.box[varCoord.c1] : panelAllocVarSize + ); + } + } + } + } if (this.geom.position == St.Side.TOP) { let childBoxLeftCorner = new Clutter.ActorBox(); let childBoxRightCorner = new Clutter.ActorBox(); let currentCornerSize = this.cornerSize; + let panelAllocFixedSize = box[fixedCoord.c2] - box[fixedCoord.c1]; [ , this.cornerSize] = this.panel._leftCorner.actor[sizeFunc](-1); childBoxLeftCorner[varCoord.c1] = 0; @@ -892,9 +1000,9 @@ var dtpPanel = Utils.defineClass({ //right click on an empty part of the panel, temporarily borrow and display the showapps context menu Main.layoutManager.setDummyCursorGeometry(stageX, stageY, 0, 0); - this.taskbar._showAppsIconWrapper.createMenu(); - this.taskbar._showAppsIconWrapper._menu.sourceActor = Main.layoutManager.dummyCursor; - this.taskbar._showAppsIconWrapper.popupMenu(); + this.showAppsIconWrapper.createMenu(); + this.showAppsIconWrapper._menu.sourceActor = Main.layoutManager.dummyCursor; + this.showAppsIconWrapper.popupMenu(); return Clutter.EVENT_STOP; } else if (Main.modalCount > 0 || event.get_source() != actor || @@ -939,9 +1047,7 @@ var dtpPanel = Utils.defineClass({ }, _onBoxActorAdded: function(box) { - if (!this._setClockLocation(Me.settings.get_string('location-clock'))) { - this._setRightCornerStyle(); - } + this._setRightCornerStyle(); if (checkIfVertical()) { this._setVertical(box, true); @@ -1001,12 +1107,6 @@ var dtpPanel = Utils.defineClass({ this._unmappedButtons.splice(this._unmappedButtons.indexOf(actor), 1); }, - _setActivitiesButtonVisible: function(isVisible) { - if(this.statusArea.activities) - isVisible ? this.statusArea.activities.container.show() : - this.statusArea.activities.container.hide(); - }, - _setAppmenuVisible: function(isVisible) { let parent; let appMenu = this.statusArea.appMenu; @@ -1019,12 +1119,7 @@ var dtpPanel = Utils.defineClass({ } if (isVisible && appMenu) { - let taskbarPosition = Me.settings.get_string('taskbar-position'); - if (taskbarPosition == 'CENTEREDCONTENT' || taskbarPosition == 'CENTEREDMONITOR') { - this._leftBox.insert_child_above(appMenu.container, null); - } else { - this._centerBox.insert_child_at_index(appMenu.container, 0); - } + this._leftBox.insert_child_above(appMenu.container, null); } }, @@ -1070,47 +1165,12 @@ var dtpPanel = Utils.defineClass({ } }, - _setClockLocation: function(loc) { - if(!this.statusArea.dateMenu) - return; - - let dateMenuContainer = this.statusArea.dateMenu.container; - let parent = dateMenuContainer.get_parent(); - let destination; - let refSibling = null; - - if (!parent) { - return; - } - - if (loc.indexOf('BUTTONS') == 0) { - destination = this._centerBox; - } else if (loc.indexOf('STATUS') == 0) { - refSibling = this.statusArea.aggregateMenu ? this.statusArea.aggregateMenu.container : null; - destination = this._rightBox; - } else { //TASKBAR - refSibling = this.taskbar.actor; - destination = refSibling.get_parent(); - } - - if (parent != destination) { - parent.remove_actor(dateMenuContainer); - destination.add_actor(dateMenuContainer); - } - - destination['set_child_' + (loc.indexOf('RIGHT') > 0 ? 'above' : 'below') + '_sibling'](dateMenuContainer, refSibling); - destination.queue_relayout(); - this._setRightCornerStyle(); - - return 1; - }, - _setRightCornerStyle: function() { if (this.panel._rightCorner) { this._toggleCornerStyle( this.panel._rightCorner, (this.statusArea.aggregateMenu && - this._rightBox.get_last_child() == this.statusArea.aggregateMenu.container) + this.panel.actor.get_last_child() == this.statusArea.aggregateMenu.container) ); } }, @@ -1121,8 +1181,8 @@ var dtpPanel = Utils.defineClass({ } }, - _displayShowDesktopButton: function (isVisible) { - if(isVisible) { + _setShowDesktopButton: function (add) { + if (add) { if(this._showDesktopButton) return; @@ -1159,15 +1219,14 @@ var dtpPanel = Utils.defineClass({  } }); - this._rightBox.insert_child_at_index(this._showDesktopButton, this._rightBox.get_children().length); + this.panel.actor.add_child(this._showDesktopButton); } else { if(!this._showDesktopButton) return; - this._rightBox.remove_child(this._showDesktopButton); + this.panel.actor.remove_child(this._showDesktopButton); this._showDesktopButton.destroy(); this._showDesktopButton = null; - this._setRightCornerStyle(); } }, diff --git a/panelManager.js b/panelManager.js index 06553c3..09b497c 100755 --- a/panelManager.js +++ b/panelManager.js @@ -30,6 +30,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); const Overview = Me.imports.overview; const Panel = Me.imports.panel; +const Pos = Me.imports.panelPositions; const Proximity = Me.imports.proximity; const Taskbar = Me.imports.taskbar; const Utils = Me.imports.utils; @@ -37,6 +38,7 @@ const Utils = Me.imports.utils; const Config = imports.misc.config; const Lang = imports.lang; const Gi = imports._gi; +const GLib = imports.gi.GLib; const Clutter = imports.gi.Clutter; const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; @@ -58,6 +60,17 @@ var dtpPanelManager = Utils.defineClass({ _init: function() { this.overview = new Overview.dtpOverview(); + this.panelsElementPositions = {}; + + //Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same + //monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()). + //Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store + //the monitors information in a setting so we can use the same monitor indexes as the ones in gnome-shell + let primaryIndex = Main.layoutManager.primaryIndex; + let monitors = [primaryIndex]; + + Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index)); + Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors)); Main.overview.viewSelector.appDisplay._views.forEach(v => { Utils.wrapActor(v.view); @@ -67,8 +80,6 @@ var dtpPanelManager = Utils.defineClass({ enable: function(reset) { let dtpPrimaryIndex = Me.settings.get_int('primary-monitor'); - if(dtpPrimaryIndex < 0 || dtpPrimaryIndex >= Main.layoutManager.monitors.length) - dtpPrimaryIndex = Main.layoutManager.primaryIndex; this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex]; this.proximityManager = new Proximity.ProximityManager(); @@ -115,6 +126,7 @@ var dtpPanelManager = Utils.defineClass({ }); } + this._updatePanelElementPositions(); this.setFocusedMonitor(this.dtpPrimaryMonitor); if (Panel.checkIfVertical()) { @@ -229,12 +241,16 @@ var dtpPanelManager = Utils.defineClass({ 'changed::primary-monitor', 'changed::multi-monitors', 'changed::isolate-monitors', - 'changed::taskbar-position', 'changed::panel-position', 'changed::stockgs-keep-top-panel' ], () => this._reset() ], + [ + Me.settings, + 'changed::panel-element-positions', + () => this._updatePanelElementPositions() + ], [ Me.settings, 'changed::intellihide-key-toggle-text', @@ -407,6 +423,11 @@ var dtpPanelManager = Utils.defineClass({ this.enable(true); }, + _updatePanelElementPositions: function() { + this.panelsElementPositions = Pos.getSettingsPositions(Me.settings); + this.allPanels.forEach(p => p.updateElementPositions()); + }, + _adjustPanelMenuButton: function(button, monitor, arrowSide) { if (button) { Utils.wrapActor(button); diff --git a/panelPositions.js b/panelPositions.js new file mode 100644 index 0000000..80eab48 --- /dev/null +++ b/panelPositions.js @@ -0,0 +1,60 @@ +/* + * This file is part of the Dash-To-Panel extension for Gnome 3 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +var SHOW_APPS_BTN = 'showAppsButton'; +var ACTIVITIES_BTN = 'activitiesButton'; +var TASKBAR = 'taskbar'; +var DATE_MENU = 'dateMenu'; +var SYSTEM_MENU = 'systemMenu'; +var LEFT_BOX = 'leftBox'; +var CENTER_BOX = 'centerBox'; +var RIGHT_BOX = 'rightBox'; +var DESKTOP_BTN = 'desktopButton'; + +var STACKED_TL = 'stackedTL'; +var STACKED_BR = 'stackedBR'; +var CENTERED = 'centered'; +var CENTERED_MONITOR = 'centerMonitor'; + +var defaults = [ + { element: SHOW_APPS_BTN, visible: true, position: STACKED_TL }, + { element: ACTIVITIES_BTN, visible: false, position: STACKED_TL }, + { element: LEFT_BOX, visible: false, position: STACKED_TL }, + { element: TASKBAR, visible: true, position: STACKED_TL }, + { element: CENTER_BOX, visible: true, position: STACKED_BR }, + { element: RIGHT_BOX, visible: true, position: STACKED_BR }, + { element: DATE_MENU, visible: true, position: STACKED_BR }, + { element: SYSTEM_MENU, visible: true, position: STACKED_BR }, + { element: DESKTOP_BTN, visible: true, position: STACKED_BR }, +]; + +var optionDialogFunctions = {}; + +optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions'; +optionDialogFunctions[DESKTOP_BTN] = '_showDesktopButtonOptions'; + +function getSettingsPositions(settings) { + var positions = null; + + try { + positions = JSON.parse(settings.get_string('panel-element-positions')); + } catch(e) { + log('Error parsing positions: ' + e.message); + } + + return positions; +} \ No newline at end of file diff --git a/panelStyle.js b/panelStyle.js index 120040c..73e5072 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -193,25 +193,7 @@ var dtpPanelStyle = Utils.defineClass({ this._overrideStyle(this.panel._leftBox, leftboxContentSizeStyleLine, 0); } - - /*recurse actors */ - if(this._rightBoxOperations.length) { - let children = this.panel._rightBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._rightBoxOperations); - } - - if(this._centerBoxOperations.length) { - let children = this.panel._centerBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._centerBoxOperations); - } - - if(this._leftBoxOperations.length) { - let children = this.panel._leftBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._leftBoxOperations); - } + this._applyStylesRecursively(); /* connect signal */ this._rightBoxActorAddedID = this.panel._rightBox.connect('actor-added', @@ -248,24 +230,32 @@ var dtpPanelStyle = Utils.defineClass({ this.panel._leftBox.disconnect(this._leftBoxActorAddedID); this._restoreOriginalStyle(this.panel._rightBox); - if(this._rightBoxOperations.length) { - let children = this.panel._rightBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._rightBoxOperations, true); - } - this._restoreOriginalStyle(this.panel._centerBox); - if(this._centerBoxOperations.length) { - let children = this.panel._centerBox.get_children(); + this._restoreOriginalStyle(this.panel._leftBox); + + this._applyStylesRecursively(true); + }, + + _applyStylesRecursively: function(restore) { + /*recurse actors */ + if(this._rightBoxOperations.length) { + // add the system menu as we move it from the rightbox to the panel to position it independently + let children = this.panel._rightBox.get_children().concat([this.panel.statusArea.aggregateMenu.container]); for(let i in children) - this._recursiveApply(children[i], this._centerBoxOperations, true); + this._recursiveApply(children[i], this._rightBoxOperations, restore); + } + + if(this._centerBoxOperations.length) { + // add the date menu as we move it from the centerbox to the panel to position it independently + let children = this.panel._centerBox.get_children().concat([this.panel.statusArea.dateMenu.container]); + for(let i in children) + this._recursiveApply(children[i], this._centerBoxOperations, restore); } - this._restoreOriginalStyle(this.panel._leftBox); if(this._leftBoxOperations.length) { let children = this.panel._leftBox.get_children(); for(let i in children) - this._recursiveApply(children[i], this._leftBoxOperations, true); + this._recursiveApply(children[i], this._leftBoxOperations, restore); } }, diff --git a/prefs.js b/prefs.js index 9ae567c..d5118c9 100644 --- a/prefs.js +++ b/prefs.js @@ -35,6 +35,7 @@ const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; const N_ = function(e) { return e }; const Update = Me.imports.update; +const Pos = Me.imports.panelPositions; const SCALE_UPDATE_TIMEOUT = 500; const DEFAULT_PANEL_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ]; @@ -200,34 +201,220 @@ const Settings = new Lang.Class({ _updateVerticalRelatedOptions: function() { let position = this._settings.get_string('panel-position'); let isVertical = position == 'LEFT' || position == 'RIGHT'; - let taskbarLocationCombo = this._builder.get_object('taskbar_position_combo'); - let clockLocationCombo = this._builder.get_object('location_clock_combo'); let showDesktopWidthLabel = this._builder.get_object('show_showdesktop_width_label'); - - taskbarLocationCombo.remove_all(); - clockLocationCombo.remove_all(); - - [ - ['LEFTPANEL', isVertical ? _('Top, with plugin icons collapsed to bottom') : _('Left, with plugin icons collapsed to right')], - ['LEFTPANEL_FIXEDCENTER', isVertical ? _('Top, with fixed center plugin icons') : _('Left, with fixed center plugin icons')], - ['LEFTPANEL_FLOATCENTER', isVertical ? _('Top, with floating center plugin icons') : _('Left, with floating center plugin icons')], - ['CENTEREDMONITOR', _('Center, fixed in middle of monitor')], - ['CENTEREDCONTENT', isVertical ? _('Center, floating between top and bottom elements') : _('Center, floating between left and right elements')] - ].forEach(tl => taskbarLocationCombo.append.apply(taskbarLocationCombo, tl)); - - [ - ['BUTTONSLEFT', isVertical ? _('Top of plugin icons') : _('Left of plugin icons')], - ['BUTTONSRIGHT', isVertical ? _('Bottom of plugin icons') : _('Right of plugin icons')], - ['STATUSLEFT', isVertical ? _('Top of system indicators') : _('Left of system indicators')], - ['STATUSRIGHT', isVertical ? _('Bottom of system indicators') : _('Right of system indicators')], - ['TASKBARLEFT', isVertical ? _('Top of taskbar') : _('Left of taskbar')], - ['TASKBARRIGHT', isVertical ? _('Bottom of taskbar') : _('Right of taskbar')] - ].forEach(cl => clockLocationCombo.append.apply(clockLocationCombo, cl)); - - taskbarLocationCombo.set_active_id(this._settings.get_string('taskbar-position')); - clockLocationCombo.set_active_id(this._settings.get_string('location-clock')); showDesktopWidthLabel.set_text(isVertical ? _('Show Desktop button height (px)') : _('Show Desktop button width (px)')); + + this._displayTaskbarElementPositionsForMonitor(this.monitors[this._builder.get_object('taskbar_position_monitor_combo').get_active()]); + }, + + _displayTaskbarElementPositionsForMonitor: function(monitorIndex) { + let taskbarListBox = this._builder.get_object('taskbar_display_listbox'); + + taskbarListBox.get_children().forEach(c => c.destroy()); + + let labels = {}; + let position = this._settings.get_string('panel-position'); + let isVertical = position == 'LEFT' || position == 'RIGHT'; + let positionSettings = Pos.getSettingsPositions(this._settings); + let panelInfo = positionSettings[monitorIndex] || Pos.defaults; + let updateSettings = () => { + let newPanelInfo = []; + + taskbarListBox.get_children().forEach(c => { + newPanelInfo.push({ + element: c.id, + visible: c.visibleToggleBtn.get_active(), + position: c.positionCombo.get_active_id() + }); + }); + + positionSettings[monitorIndex] = newPanelInfo; + this._settings.set_string('panel-element-positions', JSON.stringify(positionSettings)); + }; + + labels[Pos.SHOW_APPS_BTN] = _('Show Applications button'); + labels[Pos.ACTIVITIES_BTN] = _('Activities button'); + labels[Pos.TASKBAR] = _('Taskbar'); + labels[Pos.DATE_MENU] = _('Date menu'); + labels[Pos.SYSTEM_MENU] = _('System menu'); + labels[Pos.LEFT_BOX] = _('Left box'); + labels[Pos.CENTER_BOX] = _('Center box'); + labels[Pos.RIGHT_BOX] = _('Right box'); + labels[Pos.DESKTOP_BTN] = _('Desktop button'); + + panelInfo.forEach(el => { + let row = new Gtk.ListBoxRow(); + let grid = new Gtk.Grid({ margin: 2, margin_left: 12, margin_right: 12, column_spacing: 8 }); + let upDownGrid = new Gtk.Grid({ column_spacing: 2 }); + let upBtn = new Gtk.Button({ tooltip_text: _('Move up') }); + let upImg = new Gtk.Image({ icon_name: 'go-up-symbolic', pixel_size: 12 }); + let downBtn = new Gtk.Button({ tooltip_text: _('Move down') }); + let downImg = new Gtk.Image({ icon_name: 'go-down-symbolic', pixel_size: 12 }); + let visibleToggleBtn = new Gtk.ToggleButton({ label: _('Visible'), active: el.visible }); + let positionCombo = new Gtk.ComboBoxText({ tooltip_text: _('Select element position') }); + let upDownClickHandler = limit => { + let index = row.get_index(); + + if (index != limit) { + taskbarListBox.remove(row); + taskbarListBox.insert(row, index + (!limit ? -1 : 1)); + updateSettings(); + } + }; + + positionCombo.append(Pos.STACKED_TL, isVertical ? _('Stacked top') : _('Stacked left')); + positionCombo.append(Pos.STACKED_BR, isVertical ? _('Stacked bottom') :_('Stacked right')); + positionCombo.append(Pos.CENTERED, _('Centered')); + positionCombo.append(Pos.CENTERED_MONITOR, _('Monitor Center')); + positionCombo.set_active_id(el.position); + + upBtn.connect('clicked', () => upDownClickHandler(0)); + downBtn.connect('clicked', () => upDownClickHandler(panelInfo.length - 1)); + visibleToggleBtn.connect('toggled', () => updateSettings()); + positionCombo.connect('changed', () => updateSettings()); + + upBtn.add(upImg); + downBtn.add(downImg); + + upDownGrid.add(upBtn); + upDownGrid.add(downBtn); + + grid.add(upDownGrid); + grid.add(new Gtk.Label({ label: labels[el.element], xalign: 0, hexpand: true })); + + if (Pos.optionDialogFunctions[el.element]) { + let cogImg = new Gtk.Image({ icon_name: 'emblem-system-symbolic' }); + let optionsBtn = new Gtk.Button({ tooltip_text: _('More options') }); + + optionsBtn.get_style_context().add_class('circular'); + optionsBtn.add(cogImg); + grid.add(optionsBtn); + + optionsBtn.connect('clicked', () => this[Pos.optionDialogFunctions[el.element]]()); + } + + grid.add(visibleToggleBtn); + grid.add(positionCombo); + + row.id = el.element; + row.visibleToggleBtn = visibleToggleBtn; + row.positionCombo = positionCombo; + + row.add(grid); + taskbarListBox.add(row); + }); + + taskbarListBox.show_all(); + }, + + _showShowAppsButtonOptions: function() { + let dialog = new Gtk.Dialog({ title: _('Show Applications options'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('show_applications_options'); + dialog.get_content_area().add(box); + + let fileChooser = this._builder.get_object('show_applications_icon_file_filebutton'); + let fileImage = this._builder.get_object('show_applications_current_icon_image'); + let fileFilter = new Gtk.FileFilter(); + let handleIconChange = function(newIconPath) { + if (newIconPath && GLib.file_test(newIconPath, GLib.FileTest.EXISTS)) { + let file = Gio.File.new_for_path(newIconPath) + let pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(file.read(null), 32, 32, true, null); + + fileImage.set_from_pixbuf(pixbuf); + fileChooser.set_filename(newIconPath); + } else { + newIconPath = ''; + fileImage.set_from_icon_name('view-app-grid-symbolic', 32); + fileChooser.unselect_all(); + fileChooser.set_current_folder(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)); + } + + this._settings.set_string('show-apps-icon-file', newIconPath || ''); + }; + + fileFilter.add_pixbuf_formats(); + fileChooser.filter = fileFilter; + + fileChooser.connect('file-set', widget => handleIconChange.call(this, widget.get_filename())); + handleIconChange.call(this, this._settings.get_string('show-apps-icon-file')); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('show-apps-icon-side-padding', this._settings.get_default_value('show-apps-icon-side-padding')); + this._builder.get_object('show_applications_side_padding_spinbutton').set_value(this._settings.get_int('show-apps-icon-side-padding')); + this._settings.set_value('show-apps-override-escape', this._settings.get_default_value('show-apps-override-escape')); + handleIconChange.call(this, null); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); + }, + + _showDesktopButtonOptions: function() { + let dialog = new Gtk.Dialog({ title: _('Show Desktop options'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('box_show_showdesktop_options'); + dialog.get_content_area().add(box); + + this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); + this._builder.get_object('show_showdesktop_width_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('showdesktop-button-width', widget.get_value()); + })); + + this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); + this._builder.get_object('show_showdesktop_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('show-showdesktop-delay', widget.get_value()); + })); + + this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); + this._builder.get_object('show_showdesktop_time_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('show-showdesktop-time', widget.get_value()); + })); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('showdesktop-button-width', this._settings.get_default_value('showdesktop-button-width')); + this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); + + this._settings.set_value('show-showdesktop-hover', this._settings.get_default_value('show-showdesktop-hover')); + + this._settings.set_value('show-showdesktop-delay', this._settings.get_default_value('show-showdesktop-delay')); + this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); + + this._settings.set_value('show-showdesktop-time', this._settings.get_default_value('show-showdesktop-time')); + this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); }, _setPositionRadios: function() { @@ -256,24 +443,11 @@ const Settings = new Lang.Class({ // Position option this._setPositionRadios(); + this.monitors = this._settings.get_value('available-monitors').deep_unpack(); + this._settings.connect('changed::panel-position', () => this._updateVerticalRelatedOptions()); this._updateVerticalRelatedOptions(); - this._builder.get_object('location_clock_combo').connect('changed', Lang.bind (this, function(widget) { - let activeId = widget.get_active_id(); - - if (activeId) { - this._settings.set_string('location-clock', activeId); - } - })); - this._builder.get_object('taskbar_position_combo').connect('changed', Lang.bind (this, function(widget) { - let activeId = widget.get_active_id(); - - if (activeId) { - this._settings.set_string('taskbar-position', activeId); - } - })); - // size options let panel_size_scale = this._builder.get_object('panel_size_scale'); panel_size_scale.set_range(DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length-1], DEFAULT_PANEL_SIZES[0]); @@ -513,36 +687,35 @@ const Settings = new Lang.Class({ })); //multi-monitor - let monitors = [-1]; + + for (let i = 0; i < this.monitors.length; ++i) { + //the primary index is the first one in the "available-monitors" setting + let label = !i ? _('Primary monitor') : _('Monitor ') + (i + 1); - this._builder.get_object('multimon_primary_combo').append_text(_('Default (Primary monitor)')); - - for (let i = 0, monitorNum = Gdk.Screen.get_default().get_n_monitors(); i < monitorNum; ++i) { - this._builder.get_object('multimon_primary_combo').append_text(_('Monitor ') + (i+1)); - monitors.push(i); + this._builder.get_object('multimon_primary_combo').append_text(label); + this._builder.get_object('taskbar_position_monitor_combo').append_text(label); } - this._builder.get_object('multimon_primary_combo').set_active(monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._builder.get_object('multimon_primary_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._builder.get_object('taskbar_position_monitor_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_int('primary-monitor', monitors[widget.get_active()]); + this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]); })); + this._builder.get_object('taskbar_position_monitor_combo').connect('changed', Lang.bind (this, function(widget) { + this._displayTaskbarElementPositionsForMonitor(this.monitors[widget.get_active()]); + })); + + //taskbar element positions + this._displayTaskbarElementPositionsForMonitor(this.monitors[this._builder.get_object('multimon_primary_combo').get_active()]); + this._settings.bind('multi-monitors', this._builder.get_object('multimon_multi_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-clock-all-monitors', - this._builder.get_object('multimon_multi_show_clock_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - this._settings.bind('show-status-menu-all-monitors', - this._builder.get_object('multimon_multi_show_status_menu_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - if (monitors.length === 1) { + if (this.monitors.length === 1) { this._builder.get_object('multimon_multi_switch').set_active(false); } @@ -835,102 +1008,20 @@ const Settings = new Lang.Class({ // Behavior panel - this._settings.bind('show-show-apps-button', - this._builder.get_object('show_applications_button_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - this._settings.bind('show-show-apps-button', - this._builder.get_object('show_application_options_button'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); - this._builder.get_object('show_applications_side_padding_spinbutton').set_value(this._settings.get_int('show-apps-icon-side-padding')); this._builder.get_object('show_applications_side_padding_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { this._settings.set_int('show-apps-icon-side-padding', widget.get_value()); })); - this._builder.get_object('show_application_options_button').connect('clicked', Lang.bind(this, function() { - let dialog = new Gtk.Dialog({ title: _('Show Applications options'), - transient_for: this.widget.get_toplevel(), - use_header_bar: true, - modal: true }); - - // GTK+ leaves positive values for application-defined response ids. - // Use +1 for the reset action - dialog.add_button(_('Reset to defaults'), 1); - - let box = this._builder.get_object('show_applications_options'); - dialog.get_content_area().add(box); - - let fileChooser = this._builder.get_object('show_applications_icon_file_filebutton'); - let fileImage = this._builder.get_object('show_applications_current_icon_image'); - let fileFilter = new Gtk.FileFilter(); - let handleIconChange = function(newIconPath) { - if (newIconPath && GLib.file_test(newIconPath, GLib.FileTest.EXISTS)) { - let file = Gio.File.new_for_path(newIconPath) - let pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(file.read(null), 32, 32, true, null); - - fileImage.set_from_pixbuf(pixbuf); - fileChooser.set_filename(newIconPath); - } else { - newIconPath = ''; - fileImage.set_from_icon_name('view-app-grid-symbolic', 32); - fileChooser.unselect_all(); - fileChooser.set_current_folder(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)); - } - - this._settings.set_string('show-apps-icon-file', newIconPath || ''); - }; - - fileFilter.add_pixbuf_formats(); - fileChooser.filter = fileFilter; - - fileChooser.connect('file-set', widget => handleIconChange.call(this, widget.get_filename())); - handleIconChange.call(this, this._settings.get_string('show-apps-icon-file')); - - dialog.connect('response', Lang.bind(this, function(dialog, id) { - if (id == 1) { - // restore default settings - this._settings.set_value('show-apps-icon-side-padding', this._settings.get_default_value('show-apps-icon-side-padding')); - this._builder.get_object('show_applications_side_padding_spinbutton').set_value(this._settings.get_int('show-apps-icon-side-padding')); - this._settings.set_value('show-apps-override-escape', this._settings.get_default_value('show-apps-override-escape')); - handleIconChange.call(this, null); - } else { - // remove the settings box so it doesn't get destroyed; - dialog.get_content_area().remove(box); - dialog.destroy(); - } - return; - })); - - dialog.show_all(); - })); - this._settings.bind('animate-show-apps', - this._builder.get_object('application_button_animation_button'), + this._builder.get_object('application_button_animation_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-show-apps-button', - this._builder.get_object('application_button_animation_button'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('show-apps-override-escape', this._builder.get_object('show_applications_esc_key_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-activities-button', - this._builder.get_object('show_activities_button_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-showdesktop-button', - this._builder.get_object('show_showdesktop_button_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-showdesktop-button', - this._builder.get_object('show_showdesktop_options_button'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); this._settings.bind('show-showdesktop-hover', this._builder.get_object('show_showdesktop_hide_switch'), @@ -942,59 +1033,6 @@ const Settings = new Lang.Class({ 'sensitive', Gio.SettingsBindFlags.DEFAULT); - this._builder.get_object('show_showdesktop_options_button').connect('clicked', Lang.bind(this, function() { - - let dialog = new Gtk.Dialog({ title: _('Show Desktop options'), - transient_for: this.widget.get_toplevel(), - use_header_bar: true, - modal: true }); - - // GTK+ leaves positive values for application-defined response ids. - // Use +1 for the reset action - dialog.add_button(_('Reset to defaults'), 1); - - let box = this._builder.get_object('box_show_showdesktop_options'); - dialog.get_content_area().add(box); - - this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); - this._builder.get_object('show_showdesktop_width_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('showdesktop-button-width', widget.get_value()); - })); - - this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); - this._builder.get_object('show_showdesktop_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('show-showdesktop-delay', widget.get_value()); - })); - - this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); - this._builder.get_object('show_showdesktop_time_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('show-showdesktop-time', widget.get_value()); - })); - - dialog.connect('response', Lang.bind(this, function(dialog, id) { - if (id == 1) { - // restore default settings - this._settings.set_value('showdesktop-button-width', this._settings.get_default_value('showdesktop-button-width')); - this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); - - this._settings.set_value('show-showdesktop-hover', this._settings.get_default_value('show-showdesktop-hover')); - - this._settings.set_value('show-showdesktop-delay', this._settings.get_default_value('show-showdesktop-delay')); - this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); - - this._settings.set_value('show-showdesktop-time', this._settings.get_default_value('show-showdesktop-time')); - this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); - } else { - // remove the settings box so it doesn't get destroyed; - dialog.get_content_area().remove(box); - dialog.destroy(); - } - return; - })); - - dialog.show_all(); - })); - this._settings.bind('show-appmenu', this._builder.get_object('show_appmenu_switch'), 'active', @@ -1750,20 +1788,10 @@ const Settings = new Lang.Class({ } }; - var setGsStockPanelOptions = () => { - let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel'); - - this._builder.get_object('stockgs_top_panel_description')[keepTopPanel ? 'show' : 'hide'](); - this._builder.get_object('multimon_multi_show_clock_label').set_text(keepTopPanel ? _('Display the clock on additional panels') : _('Display the clock on secondary panels')); - this._builder.get_object('multimon_multi_show_status_menu_label').set_text(keepTopPanel ? _('Display the status menu on additional panels') : _('Display the status menu on secondary panels')); - }; - this._settings.connect('changed::stockgs-keep-top-panel', () => { - setGsStockPanelOptions(); maybeDisableTopPosition(); }); - setGsStockPanelOptions(); maybeDisableTopPosition(); this._settings.bind('stockgs-panelbtn-click-only', diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 1b80e40..64abeeb 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -25,21 +25,6 @@ - - - - - - - - - - - - - - - @@ -87,6 +72,11 @@ Panel position Panel is shown on the Bottom or Top of the screen. + + '{}' + Panel element positions + Panel element positions (JSON). + 48 Panel size @@ -207,16 +197,6 @@ Force hot corner Wheter to force having an Activities hot corner on the primary monitor - - 'STATUSLEFT' - Location of the clock - Set the location of the clock on the taskbar - - - 'LEFTPANEL' - Position of the taskbar - Set the position of the taskbar on the panel - false Lock the taskbar @@ -583,30 +563,25 @@ When the applications are ungrouped, this defines if running applications stay separate from the favorite icons. - -1 + 0 Primary monitor index - Specifies the index of the primary monitor (-1 = GNOME Primary Monitor). + Specifies the index of the primary monitor. true Display panels on all monitors Specifies if a panel is shown on every monitors + + [] + Available monitors + Available gnome-shell (Mutter) monitors, internal use + false Provide monitor isolation Dash shows only windows from the current monitor - - true - Display the clock on all monitors - Specifies if every panel should display the clock. If false, the clock is only displayed on the primary monitor. - - - true - Display the status menu on all monitors - Specifies if every panel should display the status menu. If false, the status menu is only displayed on the primary monitor. - true Display the favorites on all monitors diff --git a/stylesheet.css b/stylesheet.css index 66b2384..1f23906 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -27,7 +27,7 @@ } #dashtopanelScrollview .app-well-app .overview-icon, -#dashtopanelTaskbar .show-apps .overview-icon { +.dashtopanelMainPanel .show-apps .overview-icon { border: none; margin: 0; padding: 0; diff --git a/taskbar.js b/taskbar.js index 1f829c3..f54b89d 100644 --- a/taskbar.js +++ b/taskbar.js @@ -89,21 +89,16 @@ var taskbarActor = Utils.defineClass({ let availFixedSize = box[Panel.fixedCoord.c2] - box[Panel.fixedCoord.c1]; let availVarSize = box[Panel.varCoord.c2] - box[Panel.varCoord.c1]; - let [, showAppsButton, scrollview, leftFade, rightFade] = this.get_children(); - let [, showAppsNatSize] = showAppsButton[Panel.sizeFunc](availFixedSize); + let [, scrollview, leftFade, rightFade] = this.get_children(); let [, natSize] = this[Panel.sizeFunc](availFixedSize); let childBox = new Clutter.ActorBox(); let orientation = Panel.getOrientation(); childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1]; - childBox[Panel.fixedCoord.c1] = box[Panel.fixedCoord.c1]; - - childBox[Panel.varCoord.c2] = box[Panel.varCoord.c1] + showAppsNatSize; - childBox[Panel.fixedCoord.c2] = box[Panel.fixedCoord.c2]; - showAppsButton.allocate(childBox, flags); - - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1] + showAppsNatSize; childBox[Panel.varCoord.c2] = Math.min(availVarSize, natSize); + childBox[Panel.fixedCoord.c1] = box[Panel.fixedCoord.c1]; + childBox[Panel.fixedCoord.c2] = box[Panel.fixedCoord.c2]; + scrollview.allocate(childBox, flags); let [value, , upper, , , pageSize] = scrollview[orientation[0] + 'scroll'].adjustment.get_values(); @@ -119,7 +114,6 @@ var taskbarActor = Utils.defineClass({ rightFade.set_style(gradientStyle); } - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1] + showAppsNatSize; childBox[Panel.varCoord.c2] = childBox[Panel.varCoord.c1] + (value > 0 ? scrollview._dtpFadeSize : 0); leftFade.allocate(childBox, flags); @@ -193,8 +187,7 @@ var taskbar = Utils.defineClass({ this._scrollView.connect('scroll-event', Lang.bind(this, this._onScrollEvent )); this._scrollView.add_actor(this._box); - // Create a wrapper around the real showAppsIcon in order to add a popupMenu. - this._showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(); + this._showAppsIconWrapper = panel.showAppsIconWrapper; this._showAppsIconWrapper.connect('menu-state-changed', Lang.bind(this, function(showAppsIconWrapper, opened) { this._itemMenuStateChanged(showAppsIconWrapper, opened); })); @@ -215,7 +208,6 @@ var taskbar = Utils.defineClass({ this._hookUpLabel(this._showAppsIcon, this._showAppsIconWrapper); this._container.add_child(new St.Widget({ width: 0, reactive: false })); - this._container.add_actor(this._showAppsIcon); this._container.add_actor(this._scrollView); let orientation = Panel.getOrientation(); @@ -358,7 +350,10 @@ var taskbar = Utils.defineClass({ ], [ adjustment, - 'notify::upper', + [ + 'notify::upper', + 'notify::pageSize' + ], () => { // Update minimization animation target position on scrollview change. this._updateAppIcons(); @@ -392,7 +387,6 @@ var taskbar = Utils.defineClass({ destroy: function() { this._signalsHandler.destroy(); this._signalsHandler = 0; - this._showAppsIconWrapper.destroy(); this._container.destroy(); @@ -896,7 +890,7 @@ var taskbar = Utils.defineClass({ }, // Reset the displayed apps icon to mantain the correct order - resetAppIcons : function() { + resetAppIcons : function(geometryChange) { let children = this._getTaskbarIcons(true); for (let i = 0; i < children.length; i++) { @@ -908,8 +902,7 @@ var taskbar = Utils.defineClass({ this._shownInitially = false; this._redisplay(); - if (Panel.checkIfVertical()) { - this.showAppsButton.set_width(this.dtpPanel.geom.w); + if (geometryChange && Panel.checkIfVertical()) { this.previewMenu._updateClip(); } }, From 54ccd2d8c9860aa85648af739aa5d277f3863d77 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 12 May 2020 22:43:52 -0400 Subject: [PATCH 02/21] Adjust panel corners for in panel menus --- panel.js | 68 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/panel.js b/panel.js index 70307c3..aeee608 100644 --- a/panel.js +++ b/panel.js @@ -217,9 +217,8 @@ var dtpPanel = Utils.defineClass({ if (isStandalone && position == St.Side.TOP) { this.panel.actor.add_child(this.panel._leftCorner.actor); this.panel.actor.add_child(this.panel._rightCorner.actor); - this.panel._rightCorner.setStyleParent(this.panel.actor); } - + this.add_child(this.panel.actor); if (Main.panel._onButtonPress || Main.panel._tryDragWindow) { @@ -338,8 +337,6 @@ var dtpPanel = Utils.defineClass({ this._setAllocationMap(); - this._setRightCornerStyle(); - this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + getOrientation()); // Since Gnome 3.8 dragging an app without having opened the overview before cause the attemp to @@ -435,6 +432,8 @@ var dtpPanel = Utils.defineClass({ this._timeoutsHandler.destroy(); this._signalsHandler.destroy(); + this._disablePanelCornerSignals(); + this.panel.remove_child(this.taskbar.actor); this._setAppmenuVisible(false); @@ -492,9 +491,6 @@ var dtpPanel = Utils.defineClass({ this._setShowDesktopButton(false); - this._toggleCornerStyle(this.panel._leftCorner, true); - this._toggleCornerStyle(this.panel._rightCorner, true); - delete Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll; setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), St.Side.TOP); @@ -514,10 +510,6 @@ var dtpPanel = Utils.defineClass({ this._removePanelMenu('dateMenu'); this._removePanelMenu('aggregateMenu'); this._removePanelMenu('activities'); - - if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { - this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); - } } Main.ctrlAltTabManager.removeGroup(this); @@ -536,7 +528,9 @@ var dtpPanel = Utils.defineClass({ }, updateElementPositions: function() { - this._getElementPositions().forEach(pos => { + let panelPositions = this._getElementPositions(); + + panelPositions.forEach(pos => { let actor = this.allocationMap[pos.element].actor; if (actor) { @@ -544,6 +538,26 @@ var dtpPanel = Utils.defineClass({ } }); + this._disablePanelCornerSignals(); + + if (getPosition() == St.Side.TOP) { + let visibleElements = panelPositions.filter(pp => pp.visible); + let connectCorner = (corner, button) => { + corner._button = button; + corner._buttonStyleChangedSignalId = button.connect('style-changed', () => { + corner.set_style_pseudo_class(button.get_style_pseudo_class()); + }); + } + + if (visibleElements[0].element == Pos.ACTIVITIES_BTN) { + connectCorner(this.panel._leftCorner, this.statusArea.activities); + } + + if (visibleElements[visibleElements.length - 1].element == Pos.SYSTEM_MENU) { + connectCorner(this.panel._rightCorner, this.statusArea.aggregateMenu); + } + } + this.panel.actor.hide(); this.panel.actor.show(); }, @@ -552,6 +566,18 @@ var dtpPanel = Utils.defineClass({ return this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; }, + _disablePanelCornerSignals: function() { + if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { + this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); + delete this.panel._rightCorner._buttonStyleChangedSignalId; + } + + if (this.panel._leftCorner && this.panel._leftCorner._buttonStyleChangedSignalId) { + this.panel._leftCorner._button.disconnect(this.panel._leftCorner._buttonStyleChangedSignalId); + delete this.panel._leftCorner._buttonStyleChangedSignalId; + } + }, + _bindSettingsChanges: function() { let isVertical = checkIfVertical(); @@ -1047,8 +1073,6 @@ var dtpPanel = Utils.defineClass({ }, _onBoxActorAdded: function(box) { - this._setRightCornerStyle(); - if (checkIfVertical()) { this._setVertical(box, true); } @@ -1165,22 +1189,6 @@ var dtpPanel = Utils.defineClass({ } }, - _setRightCornerStyle: function() { - if (this.panel._rightCorner) { - this._toggleCornerStyle( - this.panel._rightCorner, - (this.statusArea.aggregateMenu && - this.panel.actor.get_last_child() == this.statusArea.aggregateMenu.container) - ); - } - }, - - _toggleCornerStyle: function(corner, visible) { - if (corner) { - corner.actor[(visible ? 'remove' : 'add') + '_style_class_name']('hidden'); - } - }, - _setShowDesktopButton: function (add) { if (add) { if(this._showDesktopButton) From 705b39fc748b752e000b55e6216e149c03550cce Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 13 May 2020 20:49:59 -0400 Subject: [PATCH 03/21] Update saved monitors on display configuration change --- panelManager.js | 25 +++++++++++++++---------- prefs.js | 12 +++++++++--- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/panelManager.js b/panelManager.js index 09b497c..277c6a5 100755 --- a/panelManager.js +++ b/panelManager.js @@ -62,15 +62,7 @@ var dtpPanelManager = Utils.defineClass({ this.overview = new Overview.dtpOverview(); this.panelsElementPositions = {}; - //Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same - //monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()). - //Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store - //the monitors information in a setting so we can use the same monitor indexes as the ones in gnome-shell - let primaryIndex = Main.layoutManager.primaryIndex; - let monitors = [primaryIndex]; - - Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index)); - Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors)); + this._saveMonitors(); Main.overview.viewSelector.appDisplay._views.forEach(v => { Utils.wrapActor(v.view); @@ -81,7 +73,7 @@ var dtpPanelManager = Utils.defineClass({ enable: function(reset) { let dtpPrimaryIndex = Me.settings.get_int('primary-monitor'); - this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex]; + this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor; this.proximityManager = new Proximity.ProximityManager(); Utils.wrapActor(Main.panel); @@ -261,6 +253,7 @@ var dtpPanelManager = Utils.defineClass({ 'monitors-changed', () => { if (Main.layoutManager.primaryMonitor) { + this._saveMonitors(); this._reset(); } } @@ -385,6 +378,18 @@ var dtpPanelManager = Utils.defineClass({ } }, + _saveMonitors: function() { + //Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same + //monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()). + //Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store + //the monitors information in a setting so we can use the same monitor indexes as the ones in gnome-shell + let primaryIndex = Main.layoutManager.primaryIndex; + let monitors = [primaryIndex]; + + Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index)); + Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors)); + }, + checkIfFocusedMonitor: function(monitor) { return Main.overview.viewSelector._workspacesDisplay._primaryIndex == monitor.index; }, diff --git a/prefs.js b/prefs.js index d5118c9..329feed 100644 --- a/prefs.js +++ b/prefs.js @@ -696,8 +696,14 @@ const Settings = new Lang.Class({ this._builder.get_object('taskbar_position_monitor_combo').append_text(label); } - this._builder.get_object('multimon_primary_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor'))); - this._builder.get_object('taskbar_position_monitor_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor'))); + let dtpPrimaryMonitorIndex = this.monitors.indexOf(this._settings.get_int('primary-monitor')); + + if (dtpPrimaryMonitorIndex < 0) { + dtpPrimaryMonitorIndex = 0; + } + + this._builder.get_object('multimon_primary_combo').set_active(dtpPrimaryMonitorIndex); + this._builder.get_object('taskbar_position_monitor_combo').set_active(dtpPrimaryMonitorIndex); this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) { this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]); @@ -716,7 +722,7 @@ const Settings = new Lang.Class({ Gio.SettingsBindFlags.DEFAULT); if (this.monitors.length === 1) { - this._builder.get_object('multimon_multi_switch').set_active(false); + this._builder.get_object('multimon_multi_switch').set_sensitive(false); } //dynamic opacity From e6795996627be4160a27ccc84667aedccc6f32ba Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 17 May 2020 08:18:20 -0400 Subject: [PATCH 04/21] Determine panel element groups --- panel.js | 284 +++++++++++++++++++++++++--------------------- panelPositions.js | 4 + 2 files changed, 160 insertions(+), 128 deletions(-) diff --git a/panel.js b/panel.js index aeee608..4016a0e 100644 --- a/panel.js +++ b/panel.js @@ -528,16 +528,8 @@ var dtpPanel = Utils.defineClass({ }, updateElementPositions: function() { - let panelPositions = this._getElementPositions(); - - panelPositions.forEach(pos => { - let actor = this.allocationMap[pos.element].actor; - - if (actor) { - actor.visible = pos.visible; - } - }); - + this._updateGroupedElements(); + this._disablePanelCornerSignals(); if (getPosition() == St.Side.TOP) { @@ -562,6 +554,56 @@ var dtpPanel = Utils.defineClass({ this.panel.actor.show(); }, + _updateGroupedElements: function() { + let panelPositions = this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; + let previousPosition = 0; + let currentGroup = -1; + + this._elementGroups = []; + + panelPositions.forEach(pos => { + let allocationMap = this.allocationMap[pos.element]; + + if (allocationMap.actor) { + allocationMap.actor.visible = pos.visible; + + if (!pos.visible) { + return; + } + + let currentPosition = pos.position; + let isCentered = Pos.checkIfCentered(currentPosition); + + if (currentPosition == Pos.STACKED_TL && previousPosition == Pos.STACKED_BR) { + currentPosition = Pos.STACKED_BR; + } + + if (!previousPosition || + (previousPosition == Pos.STACKED_TL && currentPosition != Pos.STACKED_TL) || + (previousPosition != Pos.STACKED_BR && currentPosition == Pos.STACKED_BR) || + (isCentered && previousPosition != currentPosition && previousPosition != Pos.STACKED_BR)) { + ++currentGroup; + } + + if (!this._elementGroups[currentGroup]) { + this._elementGroups[currentGroup] = { elements: [], index: this._elementGroups.length, expandableIndex: -1 }; + previousPosition = currentPosition; + } + + if (pos.element == Pos.TASKBAR) { + this._elementGroups[currentGroup].expandableIndex = this._elementGroups[currentGroup].elements.length; + } + + this._elementGroups[currentGroup].position = isCentered ? currentPosition : previousPosition; + this._elementGroups[currentGroup].isCentered = isCentered || this._elementGroups[currentGroup].isCentered; + this._elementGroups[currentGroup].elements.push(allocationMap); + + allocationMap.position = currentPosition; + previousPosition = currentPosition; + } + }); + }, + _getElementPositions: function() { return this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; }, @@ -815,151 +857,137 @@ var dtpPanel = Utils.defineClass({ this.panel.actor.allocate(new Clutter.ActorBox({ x1: 0, y1: 0, x2: this.geom.w, y2: this.geom.h }), flags); - let panelAllocVarSize = box[varCoord.c2] - box[varCoord.c1]; - let elements = []; - let centerMonitorElements = []; let fixed = 0; - let checkIfCentered = element => element.position == Pos.CENTERED || element.position == Pos.CENTERED_MONITOR; - let allocateCenter = (centeredElements, trLimit, brLimit) => { - if (centeredElements.length) { - centeredElements.filter(c => c.hasDynamicSize).forEach(c => adjustDynamicSize(c)); + let centeredMonitorGroup; + let assignGroupSize = (group, update) => { + group.size = 0; + group.tlOffset = 0; + group.brOffset = 0; - let centeredWidth = centeredElements.reduce((size, c) => size + c.natSize, 0); - let tlOffset = Math.max(0, Math.round((brLimit - trLimit - centeredWidth) * .5)); + group.elements.forEach(element => { + if (!update) { + element.box[fixedCoord.c1] = box[fixedCoord.c1]; + element.box[fixedCoord.c2] = box[fixedCoord.c2]; + element.natSize = element.actor[sizeFunc](-1)[1]; + } - centeredElements.forEach(c => { - allocate(c, trLimit + tlOffset); - trLimit += c.natSize; - }); + if (!group.isCentered || Pos.checkIfCentered(element.position)) { + group.size += element.natSize; + } else if (element.position == Pos.STACKED_TL) {  + group.tlOffset += element.natSize; + } else { // Pos.STACKED_BR + group.brOffset += element.natSize; + } + }); + + if (group.isCentered) { + group.size += Math.max(group.tlOffset, group.brOffset) * 2; + group.tlOffset = Math.max(group.tlOffset - group.brOffset, 0); } }; - let allocate = (element, c1) => { - element.box[varCoord.c1] = Math.max(0, Math.min(panelAllocVarSize, c1)); - element.box[varCoord.c2] = Math.max(element.natSize, Math.min(panelAllocVarSize, element.box[varCoord.c1] + element.natSize)); - - if (element.hasDynamicSize) { - adjustDynamicSize(element, true); - } + let allocateGroup = (group, tlLimit, brLimit) => { + let startPosition = tlLimit; + let currentPosition = 0; - element.fixed = 1; - ++fixed; + if (group.expandableIndex >= 0) { + let availableSize = brLimit - tlLimit; + let expandable = group.elements[group.expandableIndex]; + let i = 0; + let l = this._elementGroups.length; + let tlSize = 0; + let brSize = 0; - let params = [element.box, flags]; - - if (element.isBox) { - params.push(1); - } - - element.actor.allocate.apply(element.actor, params); - }; - let adjustDynamicSize = (element, adjustPos) => { - let isCentered = checkIfCentered(element); - let getSiblingsInfo = (direction, defaultLimit = 0, unfixedSize = 0, centeredSize = 0, limit = 0) => { - let j = element.index + direction; - let refElement = elements[j]; - - while (refElement && (!refElement.fixed || (isCentered && refElement.position == element.position))) { - if (isCentered && refElement.position == element.position) { - centeredSize += refElement.natSize; + if (centeredMonitorGroup && (centeredMonitorGroup != group || expandable.position != Pos.CENTERED_MONITOR)) { + if (centeredMonitorGroup.index < group.index || (centeredMonitorGroup == group && expandable.position == Pos.STACKED_TL)) { + i = centeredMonitorGroup.index; + } else { + l = centeredMonitorGroup.index; } - - unfixedSize += refElement.natSize; - refElement = elements[(j += direction)]; } - - limit = refElement ? refElement.box[varCoord[direction > 0 ? 'c1' : 'c2']] : defaultLimit; - return [unfixedSize, centeredSize, limit]; - }; - let [unfixedSizeTl, centeredSizeTl, prevLimit] = getSiblingsInfo(-1); - let [unfixedSizeBr, centeredSizeBr, nextLimit] = getSiblingsInfo(1, panelAllocVarSize); - let availableSize = nextLimit - prevLimit - unfixedSizeTl - unfixedSizeBr - - (isCentered ? Math.abs((unfixedSizeTl - centeredSizeTl) - (unfixedSizeBr - centeredSizeBr)) : 0); + for (; i < l; ++i) { + let refGroup = this._elementGroups[i]; - if (availableSize < element.natSize) { - element.natSize = availableSize; - - if (adjustPos) { - element.box[varCoord.c1] = Math.max(prevLimit + unfixedSizeTl, element.box[varCoord.c1]); - element.box[varCoord.c2] = Math.min(nextLimit - unfixedSizeBr, element.box[varCoord.c2]); + if (i < group.index && (!refGroup.fixed || refGroup[varCoord.c2] > tlLimit)) { + tlSize += refGroup.size; + } else if (i > group.index && (!refGroup.fixed || refGroup[varCoord.c1] < brLimit)) { + brSize += refGroup.size; + } + } + + if (group.isCentered) { + availableSize -= Math.max(tlSize, brSize) * 2; + } else { + availableSize -= tlSize + brSize; + } + + if (availableSize < group.size) { + expandable.natSize -= (group.size - availableSize) * (group.isCentered && !Pos.checkIfCentered(expandable.position) ? .5 : 1); + assignGroupSize(group, true); } } + + if (group.isCentered) { + startPosition = tlLimit + (brLimit - tlLimit - group.size) * .5; + } else if (group.position == Pos.STACKED_BR) { + startPosition = brLimit - group.size; + } - element.hasDynamicSize = 0; + currentPosition = group.tlOffset + startPosition; + + group.elements.forEach(element => { + let params = [element.box, flags]; + + element.box[varCoord.c1] = Math.round(currentPosition); + element.box[varCoord.c2] = Math.round((currentPosition += element.natSize)); + + if (element.isBox) { + params.push(1); + } + + element.actor.allocate.apply(element.actor, params); + }); + + group[varCoord.c1] = startPosition; + group[varCoord.c2] = currentPosition; + group.fixed = 1; + ++fixed; }; - this._getElementPositions().forEach(pos => { - let element = this.allocationMap[pos.element]; - - if (element.actor && pos.visible) { - element.natSize = element.actor[sizeFunc](-1)[1]; + this._elementGroups.forEach(group => { + group.fixed = 0; - if (element.natSize <= 0) return; + assignGroupSize(group); - element.box[fixedCoord.c1] = box[fixedCoord.c1]; - element.box[fixedCoord.c2] = box[fixedCoord.c2]; - element.hasDynamicSize = pos.element == Pos.TASKBAR; - element.index = elements.length; - element.position = pos.position; - element.fixed = 0; - - if (pos.position == Pos.CENTERED_MONITOR && - (!centerMonitorElements.length || elements[element.index - 1].position == Pos.CENTERED_MONITOR)) { - centerMonitorElements.push(element); - } - - elements.push(element); + if (group.position == Pos.CENTERED_MONITOR) { + centeredMonitorGroup = group; } }); - allocateCenter(centerMonitorElements, 0, box[varCoord.c2]); + if (centeredMonitorGroup) { + allocateGroup(centeredMonitorGroup, box[varCoord.c1], box[varCoord.c2]); + } let iterations = 0; //failsafe - while (fixed < elements.length && ++iterations < 10) { - for (let i = 0, l = elements.length; i < l; ++i) { - if (elements[i].fixed) continue; + while (fixed < this._elementGroups.length && ++iterations < 10) { + for (let i = 0, l = this._elementGroups.length; i < l; ++i) { + let group = this._elementGroups[i]; - let element = elements[i]; - let prevElement = elements[i - 1]; - let nextElement = elements[i + 1]; - - if (element.position == Pos.STACKED_TL && prevElement && prevElement.position == Pos.STACKED_BR) { - element.position = Pos.STACKED_BR; + if (group.fixed) { + continue; } - if (element.position == Pos.STACKED_TL && (!prevElement || prevElement.fixed)) { - allocate(element, prevElement ? prevElement.box[varCoord.c2] : 0); - } else if (element.position == Pos.STACKED_BR && (!nextElement || nextElement.fixed)) { - let nextLimit = nextElement ? nextElement.box[varCoord.c1] : panelAllocVarSize; - - allocate(element, nextLimit - element.natSize); - } else if (checkIfCentered(element)) { //fallback for non contiguous CENTERED_MONITOR - let centeredElements = [element]; - let j = i; + let prevGroup = this._elementGroups[i - 1]; + let nextGroup = this._elementGroups[i + 1]; + let prevLimit = prevGroup && prevGroup.fixed ? prevGroup[varCoord.c2] : box[varCoord.c1]; + let nextLimit = nextGroup && nextGroup.fixed ? nextGroup[varCoord.c1] : box[varCoord.c2]; - while (prevElement && prevElement.position == Pos.STACKED_BR) { - prevElement = elements[--j]; - } - - if (prevElement && !prevElement.fixed) continue; - - while (nextElement && checkIfCentered(nextElement)) { - centeredElements.push(nextElement); - nextElement = elements[++i + 1]; - } - - j = i; - while (nextElement && nextElement.position == Pos.STACKED_TL) { - nextElement = elements[++j]; - } - - if (!nextElement || (nextElement.fixed)) { - allocateCenter( - centeredElements, - prevElement ? prevElement.box[varCoord.c2] : 0, - nextElement ? nextElement.box[varCoord.c1] : panelAllocVarSize - ); - } + if (group.position == Pos.STACKED_TL) { + allocateGroup(group, box[varCoord.c1], nextLimit); + } else if (group.position == Pos.STACKED_BR) { + allocateGroup(group, prevLimit, box[varCoord.c2]); + } else if ((!prevGroup || prevGroup.fixed) && (!nextGroup || nextGroup.fixed)) { // CENTERED + allocateGroup(group, prevLimit, nextLimit); } } } diff --git a/panelPositions.js b/panelPositions.js index 80eab48..97ee0c5 100644 --- a/panelPositions.js +++ b/panelPositions.js @@ -57,4 +57,8 @@ function getSettingsPositions(settings) { } return positions; +} + +function checkIfCentered(position) { + return position == CENTERED || position == CENTERED_MONITOR; } \ No newline at end of file From a909283aa68b2c20fc7bd53d3a404f0b09bcc9fa Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 17 May 2020 08:26:49 -0400 Subject: [PATCH 05/21] Adjust scrollview size on taskbar enable --- taskbar.js | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/taskbar.js b/taskbar.js index f54b89d..4a66315 100644 --- a/taskbar.js +++ b/taskbar.js @@ -354,33 +354,13 @@ var taskbar = Utils.defineClass({ 'notify::upper', 'notify::pageSize' ], - () => { - // Update minimization animation target position on scrollview change. - this._updateAppIcons(); - - // When applications are ungrouped and there is some empty space on the horizontal taskbar, - // force a fixed label width to prevent the icons from "wiggling" when an animation runs - // (adding or removing an icon). When the taskbar is full, revert to a dynamic label width - // to allow them to resize and make room for new icons. - if (!isVertical && !this.isGroupApps) { - let initial = this.fullScrollView; - - if (!this.fullScrollView && Math.floor(adjustment.upper) > adjustment.page_size) { - this.fullScrollView = adjustment.page_size; - } else if (adjustment.page_size < this.fullScrollView) { - this.fullScrollView = 0; - } - - if (initial != this.fullScrollView) { - this._getAppIcons().forEach(a => a.updateTitleStyle()); - } - } - } + () => this._onScrollSizeChange(adjustment) ] ); this.isGroupApps = Me.settings.get_boolean('group-apps'); + this._onScrollSizeChange(adjustment); this._connectWorkspaceSignals(); }, @@ -439,6 +419,29 @@ var taskbar = Utils.defineClass({ }, + _onScrollSizeChange: function(adjustment) { + // Update minimization animation target position on scrollview change. + this._updateAppIcons(); + + // When applications are ungrouped and there is some empty space on the horizontal taskbar, + // force a fixed label width to prevent the icons from "wiggling" when an animation runs + // (adding or removing an icon). When the taskbar is full, revert to a dynamic label width + // to allow them to resize and make room for new icons. + if (!Panel.checkIfVertical() && !this.isGroupApps) { + let initial = this.fullScrollView; + + if (!this.fullScrollView && Math.floor(adjustment.upper) > adjustment.page_size) { + this.fullScrollView = adjustment.page_size; + } else if (adjustment.page_size < this.fullScrollView) { + this.fullScrollView = 0; + } + + if (initial != this.fullScrollView) { + this._getAppIcons().forEach(a => a.updateTitleStyle()); + } + } + }, + _onDragBegin: function() { this._dragCancelled = false; this._dragMonitor = { From f907ccca4ab76c0d3dceeebd4a5a31778fcf9252 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 17 May 2020 09:42:07 -0400 Subject: [PATCH 06/21] Add setting to sync positions on every monitor --- Settings.ui | 51 ++++++++++++------- panel.js | 11 ++-- prefs.js | 18 +++++-- ...shell.extensions.dash-to-panel.gschema.xml | 5 ++ stylesheet.css | 2 + 5 files changed, 62 insertions(+), 25 deletions(-) diff --git a/Settings.ui b/Settings.ui index 118d7f4..4cfd151 100644 --- a/Settings.ui +++ b/Settings.ui @@ -1,18 +1,18 @@ - + - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 True @@ -1993,22 +1993,22 @@ 100 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 255 @@ -4026,10 +4026,10 @@ - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 2000 @@ -4265,16 +4265,16 @@ - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 True @@ -4478,6 +4478,23 @@ 0 + + + Apply position changes to all monitors + True + True + False + 12 + True + + + 0 + 1 + + + + + False diff --git a/panel.js b/panel.js index 4016a0e..db6bd82 100644 --- a/panel.js +++ b/panel.js @@ -528,7 +528,9 @@ var dtpPanel = Utils.defineClass({ }, updateElementPositions: function() { - this._updateGroupedElements(); + let panelPositions = this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; + + this._updateGroupedElements(panelPositions); this._disablePanelCornerSignals(); @@ -554,8 +556,7 @@ var dtpPanel = Utils.defineClass({ this.panel.actor.show(); }, - _updateGroupedElements: function() { - let panelPositions = this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; + _updateGroupedElements: function(panelPositions) { let previousPosition = 0; let currentGroup = -1; @@ -1004,8 +1005,8 @@ var dtpPanel = Utils.defineClass({ childBoxLeftCorner[fixedCoord.c1] = panelAllocFixedSize; childBoxLeftCorner[fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; - childBoxRightCorner[varCoord.c1] = panelAllocVarSize - this.cornerSize; - childBoxRightCorner[varCoord.c2] = panelAllocVarSize; + childBoxRightCorner[varCoord.c1] = box[varCoord.c2] - this.cornerSize; + childBoxRightCorner[varCoord.c2] = box[varCoord.c2]; childBoxRightCorner[fixedCoord.c1] = panelAllocFixedSize; childBoxRightCorner[fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; diff --git a/prefs.js b/prefs.js index 329feed..7dc75e0 100644 --- a/prefs.js +++ b/prefs.js @@ -220,6 +220,8 @@ const Settings = new Lang.Class({ let panelInfo = positionSettings[monitorIndex] || Pos.defaults; let updateSettings = () => { let newPanelInfo = []; + let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); + let monitors = monitorSync ? this.monitors : [monitorIndex]; taskbarListBox.get_children().forEach(c => { newPanelInfo.push({ @@ -229,7 +231,7 @@ const Settings = new Lang.Class({ }); }); - positionSettings[monitorIndex] = newPanelInfo; + monitors.forEach(m => positionSettings[m] = newPanelInfo); this._settings.set_string('panel-element-positions', JSON.stringify(positionSettings)); }; @@ -263,8 +265,8 @@ const Settings = new Lang.Class({ } }; - positionCombo.append(Pos.STACKED_TL, isVertical ? _('Stacked top') : _('Stacked left')); - positionCombo.append(Pos.STACKED_BR, isVertical ? _('Stacked bottom') :_('Stacked right')); + positionCombo.append(Pos.STACKED_TL, isVertical ? _('Stacked to top') : _('Stacked to left')); + positionCombo.append(Pos.STACKED_BR, isVertical ? _('Stacked to bottom') :_('Stacked to right')); positionCombo.append(Pos.CENTERED, _('Centered')); positionCombo.append(Pos.CENTERED_MONITOR, _('Monitor Center')); positionCombo.set_active_id(el.position); @@ -705,6 +707,16 @@ const Settings = new Lang.Class({ this._builder.get_object('multimon_primary_combo').set_active(dtpPrimaryMonitorIndex); this._builder.get_object('taskbar_position_monitor_combo').set_active(dtpPrimaryMonitorIndex); + this._settings.bind('panel-element-positions-monitors-sync', + this._builder.get_object('taskbar_position_sync_button'), + 'active', + Gio.SettingsBindFlags.DEFAULT); + + this._settings.bind('panel-element-positions-monitors-sync', + this._builder.get_object('taskbar_position_monitor_combo'), + 'sensitive', + Gio.SettingsBindFlags.INVERT_BOOLEAN); + this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) { this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]); })); diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 64abeeb..147a8a0 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -72,6 +72,11 @@ Panel position Panel is shown on the Bottom or Top of the screen. + + true + Sync element positions + Sync panel element positions on all monitors. + '{}' Panel element positions diff --git a/stylesheet.css b/stylesheet.css index 1f23906..126789e 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -28,6 +28,7 @@ #dashtopanelScrollview .app-well-app .overview-icon, .dashtopanelMainPanel .show-apps .overview-icon { + background: none; border: none; margin: 0; padding: 0; @@ -43,6 +44,7 @@ background: none; } +.dashtopanelMainPanel .show-apps:hover .overview-icon, #dashtopanelScrollview .app-well-app:hover .dtp-container, #dashtopanelScrollview .app-well-app:focus .dtp-container { background-color: rgba(238, 238, 236, 0.1); From ec63802ac85c1bf39a24e075d367b2cd2e4e7c15 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 17 May 2020 11:41:45 -0400 Subject: [PATCH 07/21] Consider panelBox padding in allocation --- panel.js | 19 ++++++++++--------- panelPositions.js | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/panel.js b/panel.js index db6bd82..5b2b08d 100644 --- a/panel.js +++ b/panel.js @@ -856,10 +856,9 @@ var dtpPanel = Utils.defineClass({ vfunc_allocate: function(box, flags) { this.set_allocation(box, flags); - this.panel.actor.allocate(new Clutter.ActorBox({ x1: 0, y1: 0, x2: this.geom.w, y2: this.geom.h }), flags); - let fixed = 0; let centeredMonitorGroup; + let panelAlloc = new Clutter.ActorBox({ x1: 0, y1: 0, x2: this.geom.w, y2: this.geom.h }); let assignGroupSize = (group, update) => { group.size = 0; group.tlOffset = 0; @@ -867,8 +866,8 @@ var dtpPanel = Utils.defineClass({ group.elements.forEach(element => { if (!update) { - element.box[fixedCoord.c1] = box[fixedCoord.c1]; - element.box[fixedCoord.c2] = box[fixedCoord.c2]; + element.box[fixedCoord.c1] = panelAlloc[fixedCoord.c1]; + element.box[fixedCoord.c2] = panelAlloc[fixedCoord.c2]; element.natSize = element.actor[sizeFunc](-1)[1]; } @@ -955,6 +954,8 @@ var dtpPanel = Utils.defineClass({ ++fixed; }; + this.panel.actor.allocate(panelAlloc, flags); + this._elementGroups.forEach(group => { group.fixed = 0; @@ -966,7 +967,7 @@ var dtpPanel = Utils.defineClass({ }); if (centeredMonitorGroup) { - allocateGroup(centeredMonitorGroup, box[varCoord.c1], box[varCoord.c2]); + allocateGroup(centeredMonitorGroup, panelAlloc[varCoord.c1], panelAlloc[varCoord.c2]); } let iterations = 0; //failsafe @@ -980,13 +981,13 @@ var dtpPanel = Utils.defineClass({ let prevGroup = this._elementGroups[i - 1]; let nextGroup = this._elementGroups[i + 1]; - let prevLimit = prevGroup && prevGroup.fixed ? prevGroup[varCoord.c2] : box[varCoord.c1]; - let nextLimit = nextGroup && nextGroup.fixed ? nextGroup[varCoord.c1] : box[varCoord.c2]; + let prevLimit = prevGroup && prevGroup.fixed ? prevGroup[varCoord.c2] : panelAlloc[varCoord.c1]; + let nextLimit = nextGroup && nextGroup.fixed ? nextGroup[varCoord.c1] : panelAlloc[varCoord.c2]; if (group.position == Pos.STACKED_TL) { - allocateGroup(group, box[varCoord.c1], nextLimit); + allocateGroup(group, panelAlloc[varCoord.c1], nextLimit); } else if (group.position == Pos.STACKED_BR) { - allocateGroup(group, prevLimit, box[varCoord.c2]); + allocateGroup(group, prevLimit, panelAlloc[varCoord.c2]); } else if ((!prevGroup || prevGroup.fixed) && (!nextGroup || nextGroup.fixed)) { // CENTERED allocateGroup(group, prevLimit, nextLimit); } diff --git a/panelPositions.js b/panelPositions.js index 97ee0c5..b635803 100644 --- a/panelPositions.js +++ b/panelPositions.js @@ -33,7 +33,7 @@ var CENTERED_MONITOR = 'centerMonitor'; var defaults = [ { element: SHOW_APPS_BTN, visible: true, position: STACKED_TL }, { element: ACTIVITIES_BTN, visible: false, position: STACKED_TL }, - { element: LEFT_BOX, visible: false, position: STACKED_TL }, + { element: LEFT_BOX, visible: true, position: STACKED_TL }, { element: TASKBAR, visible: true, position: STACKED_TL }, { element: CENTER_BOX, visible: true, position: STACKED_BR }, { element: RIGHT_BOX, visible: true, position: STACKED_BR }, From 20e3012ab56bc30bf702e7f42a25be2bdadf353d Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 17 May 2020 12:26:46 -0400 Subject: [PATCH 08/21] Fix actor reference on older gnome-shell versions --- panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panel.js b/panel.js index 5b2b08d..4151ff6 100644 --- a/panel.js +++ b/panel.js @@ -434,7 +434,7 @@ var dtpPanel = Utils.defineClass({ this._signalsHandler.destroy(); this._disablePanelCornerSignals(); - this.panel.remove_child(this.taskbar.actor); + this.panel.actor.remove_child(this.taskbar.actor); this._setAppmenuVisible(false); if (this.intellihide) { From 897ef0aad662222b9597c4bedef4b97dcbadb99a Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Mon, 18 May 2020 12:16:21 -0400 Subject: [PATCH 09/21] Ensure declared element groups on first panel allocation --- panel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/panel.js b/panel.js index 4151ff6..52e33d3 100644 --- a/panel.js +++ b/panel.js @@ -141,6 +141,7 @@ var dtpPanel = Utils.defineClass({ this._sessionStyle = null; this._unmappedButtons = []; + this._elementGroups = []; this.cornerSize = 0; if (isStandalone) { From e62cbfdd0f1a4c0e0c2927e7823b21ec1cff5bb7 Mon Sep 17 00:00:00 2001 From: CharlesG Date: Mon, 18 May 2020 18:59:22 -0400 Subject: [PATCH 10/21] Fix more actor references for older gnome-shell versions --- panel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panel.js b/panel.js index 52e33d3..ab0c83e 100644 --- a/panel.js +++ b/panel.js @@ -471,13 +471,13 @@ var dtpPanel = Utils.defineClass({ ['vertical', 'horizontal', 'dashtopanelMainPanel'].forEach(c => this.panel.actor.remove_style_class_name(c)); if (!Main.sessionMode.isLocked) { - this.panel.remove_child(this.statusArea.activities.container); + this.panel.actor.remove_child(this.statusArea.activities.container); this._leftBox.insert_child_at_index(this.statusArea.activities.container, 0); - this.panel.remove_child(this.statusArea.dateMenu.container); + this.panel.actor.remove_child(this.statusArea.dateMenu.container); this._centerBox.insert_child_at_index(this.statusArea.dateMenu.container, 0); - this.panel.remove_child(this.statusArea.aggregateMenu.container); + this.panel.actor.remove_child(this.statusArea.aggregateMenu.container); this._rightBox.add_child(this.statusArea.aggregateMenu.container); if (this.statusArea.appMenu) { From 217881bb6bfa91f157bfe79f955ecf335ec71bfe Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 22 May 2020 22:43:28 -0400 Subject: [PATCH 11/21] Fix centered position with multiple stacked left --- panel.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/panel.js b/panel.js index ab0c83e..30b5711 100644 --- a/panel.js +++ b/panel.js @@ -559,6 +559,7 @@ var dtpPanel = Utils.defineClass({ _updateGroupedElements: function(panelPositions) { let previousPosition = 0; + let previousCenteredPosition = 0; let currentGroup = -1; this._elementGroups = []; @@ -584,20 +585,20 @@ var dtpPanel = Utils.defineClass({ (previousPosition == Pos.STACKED_TL && currentPosition != Pos.STACKED_TL) || (previousPosition != Pos.STACKED_BR && currentPosition == Pos.STACKED_BR) || (isCentered && previousPosition != currentPosition && previousPosition != Pos.STACKED_BR)) { - ++currentGroup; - } - - if (!this._elementGroups[currentGroup]) { - this._elementGroups[currentGroup] = { elements: [], index: this._elementGroups.length, expandableIndex: -1 }; - previousPosition = currentPosition; + this._elementGroups[++currentGroup] = { elements: [], index: this._elementGroups.length, expandableIndex: -1 }; + previousCenteredPosition = 0; } if (pos.element == Pos.TASKBAR) { this._elementGroups[currentGroup].expandableIndex = this._elementGroups[currentGroup].elements.length; } - this._elementGroups[currentGroup].position = isCentered ? currentPosition : previousPosition; - this._elementGroups[currentGroup].isCentered = isCentered || this._elementGroups[currentGroup].isCentered; + if (isCentered && !this._elementGroups[currentGroup].isCentered) { + this._elementGroups[currentGroup].isCentered = 1; + previousCenteredPosition = currentPosition; + } + + this._elementGroups[currentGroup].position = previousCenteredPosition || currentPosition; this._elementGroups[currentGroup].elements.push(allocationMap); allocationMap.position = currentPosition; From 5ee26b2c32fa11183850b625fc1647f7baeb6924 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 27 May 2020 22:02:04 -0400 Subject: [PATCH 12/21] Change focused monitor on activities button click --- panel.js | 13 +++++++++++++ taskbar.js | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/panel.js b/panel.js index 30b5711..45dd5de 100644 --- a/panel.js +++ b/panel.js @@ -370,6 +370,16 @@ var dtpPanel = Utils.defineClass({ ], () => this._adjustForOverview() ], + [ + this.statusArea.activities, + 'captured-event', + (actor, e) => { + if (e.type() == Clutter.EventType.BUTTON_PRESS || e.type() == Clutter.EventType.TOUCH_BEGIN) { + //temporarily use as primary the monitor on which the activities btn was clicked + this.panelManager.setFocusedMonitor(this.monitor, true); + } + } + ], [ this._centerBox, 'actor-added', @@ -753,6 +763,9 @@ var dtpPanel = Utils.defineClass({ if (isOverviewFocusedMonitor) { Utils.getPanelGhost().set_size(1, this.geom.position == St.Side.TOP ? 0 : 32); } + } else if (this.isPrimary) { + //reset the primary monitor when exiting the overview + this.panelManager.setFocusedMonitor(this.monitor, true); } }, diff --git a/taskbar.js b/taskbar.js index 4a66315..bdadcb8 100644 --- a/taskbar.js +++ b/taskbar.js @@ -1156,13 +1156,12 @@ var taskbar = Utils.defineClass({ } } - //temporarily use as primary the monitor on which the showapps btn was clicked + //temporarily use as primary the monitor on which the showapps btn was clicked, this is + //restored by the panel when exiting the overview this.dtpPanel.panelManager.setFocusedMonitor(this.dtpPanel.monitor); - //reset the primary monitor when exiting the overview let overviewHiddenId = Main.overview.connect('hidden', () => { Main.overview.disconnect(overviewHiddenId); - this.dtpPanel.panelManager.setFocusedMonitor(this.dtpPanel.panelManager.primaryPanel.monitor, true); delete Main.overview.viewSelector._onStageKeyPress; }); From 7e9cd84e951d1ebb337509e5914910eb495557e0 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 28 May 2020 17:47:12 -0400 Subject: [PATCH 13/21] Reset primary monitor when overview is hidden --- panel.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/panel.js b/panel.js index 45dd5de..55f2ae4 100644 --- a/panel.js +++ b/panel.js @@ -370,6 +370,16 @@ var dtpPanel = Utils.defineClass({ ], () => this._adjustForOverview() ], + [ + Main.overview, + 'hidden', + () => { + if (this.isPrimary) { + //reset the primary monitor when exiting the overview + this.panelManager.setFocusedMonitor(this.monitor, true); + } + } + ], [ this.statusArea.activities, 'captured-event', @@ -763,9 +773,6 @@ var dtpPanel = Utils.defineClass({ if (isOverviewFocusedMonitor) { Utils.getPanelGhost().set_size(1, this.geom.position == St.Side.TOP ? 0 : 32); } - } else if (this.isPrimary) { - //reset the primary monitor when exiting the overview - this.panelManager.setFocusedMonitor(this.monitor, true); } }, From 20e996468966b07142aa3de2209ae39786802d27 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 28 May 2020 21:21:37 -0400 Subject: [PATCH 14/21] Fix initial workspace windows zoom animation in overview --- panelManager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/panelManager.js b/panelManager.js index 277c6a5..312a33f 100755 --- a/panelManager.js +++ b/panelManager.js @@ -531,12 +531,16 @@ var dtpPanelManager = Utils.defineClass({ let monitors = Main.layoutManager.monitors; for (let i = 0; i < monitors.length; i++) { + let workspaces; let view; if (this._workspacesOnlyOnPrimary && i != Main.layoutManager.primaryIndex) { view = new WorkspacesView.ExtraWorkspaceView(i); view.getActiveWorkspace = view.getActiveWorkspace || function() { return this._workspace; }; - } else + workspaces = [view._workspace]; + } else { view = new WorkspacesView.WorkspacesView(i, this._scrollAdjustment || 0); + workspaces = view._workspaces; + } Utils.wrapActor(view); view.actor.connect('scroll-event', this._onScrollEvent.bind(this)); @@ -546,6 +550,7 @@ var dtpPanelManager = Utils.defineClass({ this._scrollValueChanged.bind(this)); } + workspaces.forEach(w => w.setFullGeometry = geom => w._fullGeometry = geom); this._workspacesViews.push(view); } From cc5edef07e94d1ee6197ef6017410d23511f847e Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 29 May 2020 07:52:35 -0400 Subject: [PATCH 15/21] Fix activities monitor focus on older gnome-shell verions --- panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panel.js b/panel.js index 55f2ae4..7aee450 100644 --- a/panel.js +++ b/panel.js @@ -381,7 +381,7 @@ var dtpPanel = Utils.defineClass({ } ], [ - this.statusArea.activities, + this.statusArea.activities.actor, 'captured-event', (actor, e) => { if (e.type() == Clutter.EventType.BUTTON_PRESS || e.type() == Clutter.EventType.TOUCH_BEGIN) { From 8b6b04d04dffd2d635bf1f264580cc49e016b81c Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 29 May 2020 16:54:36 -0400 Subject: [PATCH 16/21] Fix activities actor warning --- panel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/panel.js b/panel.js index 7aee450..bd07ca3 100644 --- a/panel.js +++ b/panel.js @@ -214,6 +214,7 @@ var dtpPanel = Utils.defineClass({ Utils.wrapActor(this.panel._leftCorner || 0); Utils.wrapActor(this.panel._rightCorner || 0); + Utils.wrapActor(this.statusArea.activities); if (isStandalone && position == St.Side.TOP) { this.panel.actor.add_child(this.panel._leftCorner.actor); @@ -788,7 +789,7 @@ var dtpPanel = Utils.defineClass({ } if (checkIfVertical()) { - this.showAppsButton.set_width(this.geom.w); + this.showAppsIconWrapper.realShowAppsIcon.toggleButton.set_width(this.geom.w); this._refreshVerticalAlloc(); this._setSearchEntryOffset(this.geom.w); } From aea236d2f4b1897742236bb9be24040c0cc34ffd Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Fri, 29 May 2020 17:41:09 -0400 Subject: [PATCH 17/21] Fix missing secondary panel allocation --- panel.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/panel.js b/panel.js index bd07ca3..7e2bd99 100644 --- a/panel.js +++ b/panel.js @@ -145,7 +145,7 @@ var dtpPanel = Utils.defineClass({ this.cornerSize = 0; if (isStandalone) { - this.panel = new St.Widget({ name: 'panel', reactive: true }); + this.panel = new dtpSecondaryPanel({ name: 'panel', reactive: true }); this.statusArea = this.panel.statusArea = {}; Utils.wrapActor(this.panel); @@ -1403,8 +1403,21 @@ var dtpPanel = Utils.defineClass({ }, }); +var dtpSecondaryPanel = Utils.defineClass({ + Name: 'DashToPanel-SecondaryPanel', + Extends: St.Widget, + + _init: function(params) { + this.callParent('_init', params); + }, + + vfunc_allocate: function(box, flags) { + this.set_allocation(box, flags); + } +}); + var dtpSecondaryAggregateMenu = Utils.defineClass({ - Name: 'dtpSecondaryAggregateMenu', + Name: 'DashToPanel-SecondaryAggregateMenu', Extends: PanelMenu.Button, _init: function() { From 20f66a5a5f473f86f349178c4759f6300b69f5a1 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sat, 13 Jun 2020 07:40:33 -0400 Subject: [PATCH 18/21] Use per panel positioning --- appIcons.js | 54 +++--- intellihide.js | 6 +- panel.js | 163 +++++++++--------- panelManager.js | 32 ++-- panelPositions.js | 4 +- panelStyle.js | 2 +- prefs.js | 2 +- ...shell.extensions.dash-to-panel.gschema.xml | 5 + taskbar.js | 44 ++--- transparency.js | 4 +- windowPreview.js | 21 ++- 11 files changed, 170 insertions(+), 167 deletions(-) diff --git a/appIcons.js b/appIcons.js index bfc9bda..ad0e82a 100644 --- a/appIcons.js +++ b/appIcons.js @@ -150,7 +150,7 @@ var taskbarAppIcon = Utils.defineClass({ this._container = new St.Widget({ style_class: 'dtp-container', layout_manager: new Clutter.BinLayout() }); this._dotsContainer = new St.Widget({ layout_manager: new Clutter.BinLayout() }); - this._dtpIconContainer = new St.Widget({ layout_manager: new Clutter.BinLayout(), style: getIconContainerStyle() }); + this._dtpIconContainer = new St.Widget({ layout_manager: new Clutter.BinLayout(), style: this.getIconContainerStyle() }); this.actor.remove_actor(this._iconContainer); @@ -181,7 +181,7 @@ var taskbarAppIcon = Utils.defineClass({ this._container.add_child(this._dotsContainer); this.actor.set_child(this._container); - if (Panel.checkIfVertical()) { + if (panel.checkIfVertical()) { this.actor.set_width(panel.geom.w); } @@ -482,7 +482,7 @@ var taskbarAppIcon = Utils.defineClass({ _updateWindowTitleStyle: function() { if (this._windowTitle) { let useFixedWidth = Me.settings.get_boolean('group-apps-use-fixed-width'); - let variableWidth = !useFixedWidth || Panel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView; + let variableWidth = !useFixedWidth || this.dtpPanel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView; let fontWeight = Me.settings.get_string('group-apps-label-font-weight'); let fontColor = this.window.minimized ? Me.settings.get_string('group-apps-label-font-color-minimized') : @@ -536,7 +536,7 @@ var taskbarAppIcon = Utils.defineClass({ let bgSvg = '/img/highlight_stacked_bg'; if (pos == DOT_POSITION.LEFT || pos == DOT_POSITION.RIGHT) { - bgSvg += (Panel.checkIfVertical() ? '_2' : '_3'); + bgSvg += (this.dtpPanel.checkIfVertical() ? '_2' : '_3'); } inlineStyle += "background-image: url('" + Me.path + bgSvg + ".svg');" + @@ -575,7 +575,7 @@ var taskbarAppIcon = Utils.defineClass({ let padding = getIconPadding(); let margin = Me.settings.get_int('appicon-margin'); - this.actor.set_style('padding:' + (Panel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;')); + this.actor.set_style('padding:' + (this.dtpPanel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;')); this._iconContainer.set_style('padding: ' + padding + 'px;'); }, @@ -588,7 +588,7 @@ var taskbarAppIcon = Utils.defineClass({ } if (!this._menu) { - this._menu = new taskbarSecondaryMenu(this); + this._menu = new taskbarSecondaryMenu(this, this.dtpPanel); this._menu.connect('activate-window', Lang.bind(this, function (menu, window) { this.activateWindow(window, Me.settings); })); @@ -1223,24 +1223,23 @@ var taskbarAppIcon = Utils.defineClass({ getAppIconInterestingWindows: function(isolateMonitors) { return getInterestingWindows(this.app, this.dtpPanel.monitor, isolateMonitors); - } + }, + getIconContainerStyle: function() { + let style = 'padding: '; + let isVertical = this.dtpPanel.checkIfVertical(); + + if (Me.settings.get_boolean('group-apps')) { + style += (isVertical ? '0;' : '0 ' + DEFAULT_PADDING_SIZE + 'px;'); + } else { + style += (isVertical ? '' : '0 ') + DEFAULT_PADDING_SIZE + 'px;'; + } + + return style; + } }); taskbarAppIcon.prototype.scaleAndFade = taskbarAppIcon.prototype.undoScaleAndFade = () => {}; -function getIconContainerStyle() { - let style = 'padding: '; - let isVertical = Panel.checkIfVertical(); - - if (Me.settings.get_boolean('group-apps')) { - style += (isVertical ? '0;' : '0 ' + DEFAULT_PADDING_SIZE + 'px;'); - } else { - style += (isVertical ? '' : '0 ') + DEFAULT_PADDING_SIZE + 'px;'; - } - - return style; -} - function minimizeWindow(app, param, monitor){ // Param true make all app windows minimize let windows = getInterestingWindows(app, monitor); @@ -1403,13 +1402,13 @@ var taskbarSecondaryMenu = Utils.defineClass({ Extends: AppDisplay.AppIconMenu, ParentConstrParams: [[0]], - _init: function(source) { + _init: function(source, panel) { // Damm it, there has to be a proper way of doing this... // As I can't call the parent parent constructor (?) passing the side // parameter, I overwite what I need later this.callParent('_init', source); - let side = Panel.getPosition(); + let side = panel.getPosition(); // Change the initialized side where required. this._arrowSide = side; this._boxPointer._arrowSide = side; @@ -1544,7 +1543,7 @@ function ItemShowLabel() { let labelWidth = this.label.get_width(); let labelHeight = this.label.get_height(); - let position = Panel.getPosition(); + let position = this._dtpPanel.getPosition(); let labelOffset = node.get_length('-x-offset'); let xOffset = Math.floor((itemWidth - labelWidth) / 2); @@ -1607,7 +1606,7 @@ function ItemShowLabel() { var ShowAppsIconWrapper = Utils.defineClass({ Name: 'DashToPanel.ShowAppsIconWrapper', - _init: function() { + _init: function(dtpPanel) { this.realShowAppsIcon = new Dash.ShowAppsIcon(); Utils.wrapActor(this.realShowAppsIcon); @@ -1638,6 +1637,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ this._menuManager = new PopupMenu.PopupMenuManager(this.actor); this._menuTimeoutId = 0; + this.realShowAppsIcon._dtpPanel = dtpPanel; Taskbar.extendDashItemContainer(this.realShowAppsIcon); let customIconPath = Me.settings.get_string('show-apps-icon-file'); @@ -1698,14 +1698,14 @@ var ShowAppsIconWrapper = Utils.defineClass({ setShowAppsPadding: function() { let padding = getIconPadding(); let sidePadding = Me.settings.get_int('show-apps-icon-side-padding'); - let isVertical = Panel.checkIfVertical(); + let isVertical = this.realShowAppsIcon._dtpPanel.checkIfVertical(); this.actor.set_style('padding:' + (padding + (isVertical ? sidePadding : 0)) + 'px ' + (padding + (isVertical ? 0 : sidePadding)) + 'px;'); }, createMenu: function() { if (!this._menu) { - this._menu = new MyShowAppsIconMenu(this.actor); + this._menu = new MyShowAppsIconMenu(this.actor, this.realShowAppsIcon._dtpPanel); this._menu.connect('open-state-changed', Lang.bind(this, function(menu, isPoppedUp) { if (!isPoppedUp) this._onMenuPoppedDown(); @@ -1754,7 +1754,7 @@ Signals.addSignalMethods(ShowAppsIconWrapper.prototype); var MyShowAppsIconMenu = Utils.defineClass({ Name: 'DashToPanel.ShowAppsIconMenu', Extends: taskbarSecondaryMenu, - ParentConstrParams: [[0]], + ParentConstrParams: [[0], [1]], _dtpRedisplay: function() { this.removeAll(); diff --git a/intellihide.js b/intellihide.js index c4c9c97..7673b43 100644 --- a/intellihide.js +++ b/intellihide.js @@ -21,7 +21,7 @@ const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; const St = imports.gi.St; -const GrabHelper = imports.ui.grabHelper; +var GrabHelper = imports.ui.grabHelper; const Layout = imports.ui.layout; const Main = imports.ui.main; const OverviewControls = imports.ui.overviewControls; @@ -79,7 +79,7 @@ var Intellihide = Utils.defineClass({ this._pendingUpdate = false; this._hoveredOut = false; this._windowOverlap = false; - this._translationProp = 'translation_' + (Panel.checkIfVertical() ? 'x' : 'y'); + this._translationProp = 'translation_' + (this._dtpPanel.checkIfVertical() ? 'x' : 'y'); this._panelBox.translation_y = 0; this._panelBox.translation_x = 0; @@ -251,7 +251,7 @@ var Intellihide = Utils.defineClass({ let position = this._dtpPanel.geom.position; let opts = { display: global.display }; - if (Panel.checkIfVertical()) { + if (this._dtpPanel.checkIfVertical()) { opts.y1 = this._monitor.y; opts.y2 = this._monitor.y + this._monitor.height; opts.x1 = opts.x2 = this._monitor.x; diff --git a/panel.js b/panel.js index 7e2bd99..e2dba2a 100644 --- a/panel.js +++ b/panel.js @@ -62,10 +62,6 @@ const _ = imports.gettext.domain(Me.imports.utils.TRANSLATION_DOMAIN).gettext; let tracker = Shell.WindowTracker.get_default(); var panelBoxes = ['_leftBox', '_centerBox', '_rightBox']; -var sizeFunc; -var fixedCoord; -var varCoord; -var size; //timeout names const T1 = 'startDynamicTransparencyTimeout'; @@ -76,30 +72,6 @@ const T5 = 'trackerFocusAppTimeout'; const T6 = 'scrollPanelDelayTimeout'; const T7 = 'waitPanelBoxAllocation'; -function getPosition() { - let position = Me.settings.get_string('panel-position'); - - if (position == 'TOP') { - return St.Side.TOP; - } else if (position == 'RIGHT') { - return St.Side.RIGHT; - } else if (position == 'BOTTOM') { - return St.Side.BOTTOM; - } - - return St.Side.LEFT; -} - -function checkIfVertical() { - let position = getPosition(); - - return (position == St.Side.LEFT || position == St.Side.RIGHT); -} - -function getOrientation() { - return (checkIfVertical() ? 'vertical' : 'horizontal'); -} - function setMenuArrow(arrowIcon, side) { let parent = arrowIcon.get_parent(); let iconNames = { @@ -119,7 +91,7 @@ var dtpPanel = Utils.defineClass({ Extends: St.Widget, _init: function(panelManager, monitor, panelBox, isStandalone) { - let position = getPosition(); + let position = this.getPosition(); this.callParent('_init', { layout_manager: new Clutter.BinLayout() }); @@ -201,8 +173,7 @@ var dtpPanel = Utils.defineClass({ // Create a wrapper around the real showAppsIcon in order to add a popupMenu. Most of // its behavior is handled by the taskbar, but its positioning is done at the panel level - this.showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(); - this.showAppsIconWrapper._dtpPanel = this; + this.showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(this); this.panel.actor.add_child(this.showAppsIconWrapper.realShowAppsIcon); this.panel.actor._delegate = this; @@ -243,7 +214,7 @@ var dtpPanel = Utils.defineClass({ }, enable : function() { - let position = getPosition(); + let position = this.getPosition(); if (this.statusArea.aggregateMenu) { Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll = 1; @@ -339,7 +310,7 @@ var dtpPanel = Utils.defineClass({ this._setAllocationMap(); - this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + getOrientation()); + this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + this.getOrientation()); // Since Gnome 3.8 dragging an app without having opened the overview before cause the attemp to //animate a null target since some variables are not initialized when the viewSelector is created @@ -417,7 +388,7 @@ var dtpPanel = Utils.defineClass({ this.panelStyle.enable(this); - if (checkIfVertical()) { + if (this.checkIfVertical()) { this._signalsHandler.add([ this.panelBox, 'notify::visible', @@ -549,6 +520,30 @@ var dtpPanel = Utils.defineClass({ return DND.DragMotionResult.CONTINUE; }, + getPosition: function() { + let position = Me.settings.get_string('panel-position'); + + if (position == 'TOP') { + return St.Side.TOP; + } else if (position == 'RIGHT') { + return St.Side.RIGHT; + } else if (position == 'BOTTOM') { + return St.Side.BOTTOM; + } + + return St.Side.LEFT; + }, + + checkIfVertical: function() { + let position = this.getPosition(); + + return (position == St.Side.LEFT || position == St.Side.RIGHT); + }, + + getOrientation: function() { + return (this.checkIfVertical() ? 'vertical' : 'horizontal'); + }, + updateElementPositions: function() { let panelPositions = this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; @@ -556,7 +551,7 @@ var dtpPanel = Utils.defineClass({ this._disablePanelCornerSignals(); - if (getPosition() == St.Side.TOP) { + if (this.getPosition() == St.Side.TOP) { let visibleElements = panelPositions.filter(pp => pp.visible); let connectCorner = (corner, button) => { corner._button = button; @@ -645,7 +640,7 @@ var dtpPanel = Utils.defineClass({ }, _bindSettingsChanges: function() { - let isVertical = checkIfVertical(); + let isVertical = this.checkIfVertical(); this._signalsHandler.add( [ @@ -742,7 +737,7 @@ var dtpPanel = Utils.defineClass({ }, _setPanelGhostSize: function() { - this._myPanelGhost.set_size(this.width, checkIfVertical() ? 1 : this.height); + this._myPanelGhost.set_size(this.width, this.checkIfVertical() ? 1 : this.height); }, _setSearchEntryOffset: function(offset) { @@ -751,7 +746,7 @@ var dtpPanel = Utils.defineClass({ //that doesn't natively take into account the size of a side dock, as it is always //centered relatively to the monitor. This looks misaligned, adjust it here so it //is centered like the rest of the overview elements. - let paddingSide = getPosition() == St.Side.LEFT ? 'left' : 'right'; + let paddingSide = this.getPosition() == St.Side.LEFT ? 'left' : 'right'; let scaleFactor = Utils.getScaleFactor(); let style = offset ? 'padding-' + paddingSide + ':' + (offset / scaleFactor) + 'px;' : null; let searchEntry = Main.overview._searchEntry || Main.overview._overview._searchEntry; @@ -788,7 +783,7 @@ var dtpPanel = Utils.defineClass({ this.intellihide.reset(); } - if (checkIfVertical()) { + if (this.checkIfVertical()) { this.showAppsIconWrapper.realShowAppsIcon.toggleButton.set_width(this.geom.w); this._refreshVerticalAlloc(); this._setSearchEntryOffset(this.geom.w); @@ -801,47 +796,47 @@ var dtpPanel = Utils.defineClass({ let lrPadding = panelBoxTheme.get_padding(St.Side.RIGHT) + panelBoxTheme.get_padding(St.Side.LEFT); let topPadding = panelBoxTheme.get_padding(St.Side.TOP); let tbPadding = topPadding + panelBoxTheme.get_padding(St.Side.BOTTOM); - let position = getPosition(); + let position = this.getPosition(); let gsTopPanelOffset = 0; let x = 0, y = 0; let w = 0, h = 0; - size = Me.settings.get_int('panel-size') * scaleFactor; + this.dtpSize = Me.settings.get_int('panel-size') * scaleFactor; if (Me.settings.get_boolean('stockgs-keep-top-panel') && Main.layoutManager.primaryMonitor == this.monitor) { gsTopPanelOffset = Main.layoutManager.panelBox.height - topPadding; } - if (checkIfVertical()) { + if (this.checkIfVertical()) { if (!Me.settings.get_boolean('group-apps')) { // add window title width and side padding of _dtpIconContainer when vertical - size += Me.settings.get_int('group-apps-label-max-width') + AppIcons.DEFAULT_PADDING_SIZE * 2 / scaleFactor; + this.dtpSize += Me.settings.get_int('group-apps-label-max-width') + AppIcons.DEFAULT_PADDING_SIZE * 2 / scaleFactor; } - sizeFunc = 'get_preferred_height', - fixedCoord = { c1: 'x1', c2: 'x2' }, - varCoord = { c1: 'y1', c2: 'y2' }; + this.sizeFunc = 'get_preferred_height', + this.fixedCoord = { c1: 'x1', c2: 'x2' }, + this.varCoord = { c1: 'y1', c2: 'y2' }; - w = size; + w = this.dtpSize; h = this.monitor.height - tbPadding - gsTopPanelOffset; } else { - sizeFunc = 'get_preferred_width'; - fixedCoord = { c1: 'y1', c2: 'y2' }; - varCoord = { c1: 'x1', c2: 'x2' }; + this.sizeFunc = 'get_preferred_width'; + this.fixedCoord = { c1: 'y1', c2: 'y2' }; + this.varCoord = { c1: 'x1', c2: 'x2' }; w = this.monitor.width - lrPadding; - h = size; + h = this.dtpSize; } if (position == St.Side.TOP || position == St.Side.LEFT) { x = this.monitor.x; y = this.monitor.y + gsTopPanelOffset; } else if (position == St.Side.RIGHT) { - x = this.monitor.x + this.monitor.width - size - lrPadding; + x = this.monitor.x + this.monitor.width - this.dtpSize - lrPadding; y = this.monitor.y + gsTopPanelOffset; } else { //BOTTOM x = this.monitor.x; - y = this.monitor.y + this.monitor.height - size - tbPadding; + y = this.monitor.y + this.monitor.height - this.dtpSize - tbPadding; } return { @@ -889,9 +884,9 @@ var dtpPanel = Utils.defineClass({ group.elements.forEach(element => { if (!update) { - element.box[fixedCoord.c1] = panelAlloc[fixedCoord.c1]; - element.box[fixedCoord.c2] = panelAlloc[fixedCoord.c2]; - element.natSize = element.actor[sizeFunc](-1)[1]; + element.box[this.fixedCoord.c1] = panelAlloc[this.fixedCoord.c1]; + element.box[this.fixedCoord.c2] = panelAlloc[this.fixedCoord.c2]; + element.natSize = element.actor[this.sizeFunc](-1)[1]; } if (!group.isCentered || Pos.checkIfCentered(element.position)) { @@ -931,9 +926,9 @@ var dtpPanel = Utils.defineClass({ for (; i < l; ++i) { let refGroup = this._elementGroups[i]; - if (i < group.index && (!refGroup.fixed || refGroup[varCoord.c2] > tlLimit)) { + if (i < group.index && (!refGroup.fixed || refGroup[this.varCoord.c2] > tlLimit)) { tlSize += refGroup.size; - } else if (i > group.index && (!refGroup.fixed || refGroup[varCoord.c1] < brLimit)) { + } else if (i > group.index && (!refGroup.fixed || refGroup[this.varCoord.c1] < brLimit)) { brSize += refGroup.size; } } @@ -961,8 +956,8 @@ var dtpPanel = Utils.defineClass({ group.elements.forEach(element => { let params = [element.box, flags]; - element.box[varCoord.c1] = Math.round(currentPosition); - element.box[varCoord.c2] = Math.round((currentPosition += element.natSize)); + element.box[this.varCoord.c1] = Math.round(currentPosition); + element.box[this.varCoord.c2] = Math.round((currentPosition += element.natSize)); if (element.isBox) { params.push(1); @@ -971,8 +966,8 @@ var dtpPanel = Utils.defineClass({ element.actor.allocate.apply(element.actor, params); }); - group[varCoord.c1] = startPosition; - group[varCoord.c2] = currentPosition; + group[this.varCoord.c1] = startPosition; + group[this.varCoord.c2] = currentPosition; group.fixed = 1; ++fixed; }; @@ -990,7 +985,7 @@ var dtpPanel = Utils.defineClass({ }); if (centeredMonitorGroup) { - allocateGroup(centeredMonitorGroup, panelAlloc[varCoord.c1], panelAlloc[varCoord.c2]); + allocateGroup(centeredMonitorGroup, panelAlloc[this.varCoord.c1], panelAlloc[this.varCoord.c2]); } let iterations = 0; //failsafe @@ -1004,13 +999,13 @@ var dtpPanel = Utils.defineClass({ let prevGroup = this._elementGroups[i - 1]; let nextGroup = this._elementGroups[i + 1]; - let prevLimit = prevGroup && prevGroup.fixed ? prevGroup[varCoord.c2] : panelAlloc[varCoord.c1]; - let nextLimit = nextGroup && nextGroup.fixed ? nextGroup[varCoord.c1] : panelAlloc[varCoord.c2]; + let prevLimit = prevGroup && prevGroup.fixed ? prevGroup[this.varCoord.c2] : panelAlloc[this.varCoord.c1]; + let nextLimit = nextGroup && nextGroup.fixed ? nextGroup[this.varCoord.c1] : panelAlloc[this.varCoord.c2]; if (group.position == Pos.STACKED_TL) { - allocateGroup(group, panelAlloc[varCoord.c1], nextLimit); + allocateGroup(group, panelAlloc[this.varCoord.c1], nextLimit); } else if (group.position == Pos.STACKED_BR) { - allocateGroup(group, prevLimit, panelAlloc[varCoord.c2]); + allocateGroup(group, prevLimit, panelAlloc[this.varCoord.c2]); } else if ((!prevGroup || prevGroup.fixed) && (!nextGroup || nextGroup.fixed)) { // CENTERED allocateGroup(group, prevLimit, nextLimit); } @@ -1021,18 +1016,18 @@ var dtpPanel = Utils.defineClass({ let childBoxLeftCorner = new Clutter.ActorBox(); let childBoxRightCorner = new Clutter.ActorBox(); let currentCornerSize = this.cornerSize; - let panelAllocFixedSize = box[fixedCoord.c2] - box[fixedCoord.c1]; + let panelAllocFixedSize = box[this.fixedCoord.c2] - box[this.fixedCoord.c1]; - [ , this.cornerSize] = this.panel._leftCorner.actor[sizeFunc](-1); - childBoxLeftCorner[varCoord.c1] = 0; - childBoxLeftCorner[varCoord.c2] = this.cornerSize; - childBoxLeftCorner[fixedCoord.c1] = panelAllocFixedSize; - childBoxLeftCorner[fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; + [ , this.cornerSize] = this.panel._leftCorner.actor[this.sizeFunc](-1); + childBoxLeftCorner[this.varCoord.c1] = 0; + childBoxLeftCorner[this.varCoord.c2] = this.cornerSize; + childBoxLeftCorner[this.fixedCoord.c1] = panelAllocFixedSize; + childBoxLeftCorner[this.fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; - childBoxRightCorner[varCoord.c1] = box[varCoord.c2] - this.cornerSize; - childBoxRightCorner[varCoord.c2] = box[varCoord.c2]; - childBoxRightCorner[fixedCoord.c1] = panelAllocFixedSize; - childBoxRightCorner[fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; + childBoxRightCorner[this.varCoord.c1] = box[this.varCoord.c2] - this.cornerSize; + childBoxRightCorner[this.varCoord.c2] = box[this.varCoord.c2]; + childBoxRightCorner[this.fixedCoord.c1] = panelAllocFixedSize; + childBoxRightCorner[this.fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; this.panel._leftCorner.actor.allocate(childBoxLeftCorner, flags); this.panel._rightCorner.actor.allocate(childBoxRightCorner, flags); @@ -1049,7 +1044,7 @@ var dtpPanel = Utils.defineClass({ this.set_size(this.geom.w, this.geom.h); clipContainer.set_position(this.geom.x, this.geom.y); - this._setVertical(this.panel.actor, checkIfVertical()); + this._setVertical(this.panel.actor, this.checkIfVertical()); // styles for theming Object.keys(St.Side).forEach(p => { @@ -1090,8 +1085,8 @@ var dtpPanel = Utils.defineClass({ return Clutter.EVENT_PROPAGATE; } - let params = checkIfVertical() ? [stageY, 'y', 'height'] : [stageX, 'x', 'width']; - let dragWindow = this._getDraggableWindowForPosition.apply(this, params.concat(['maximized_' + getOrientation() + 'ly'])); + let params = this.checkIfVertical() ? [stageY, 'y', 'height'] : [stageX, 'x', 'width']; + let dragWindow = this._getDraggableWindowForPosition.apply(this, params.concat(['maximized_' + this.getOrientation() + 'ly'])); if (!dragWindow) return Clutter.EVENT_PROPAGATE; @@ -1126,7 +1121,7 @@ var dtpPanel = Utils.defineClass({ }, _onBoxActorAdded: function(box) { - if (checkIfVertical()) { + if (this.checkIfVertical()) { this._setVertical(box, true); } }, @@ -1161,8 +1156,8 @@ var dtpPanel = Utils.defineClass({ let [, natWidth] = actor.get_preferred_width(-1); child.x_align = Clutter.ActorAlign[isVertical ? 'CENTER' : 'START']; - actor.set_width(isVertical ? size : -1); - isVertical = isVertical && (natWidth > size); + actor.set_width(isVertical ? this.dtpSize : -1); + isVertical = isVertical && (natWidth > this.dtpSize); actor[(isVertical ? 'add' : 'remove') + '_style_class_name']('vertical'); } } @@ -1294,7 +1289,7 @@ var dtpPanel = Utils.defineClass({ _setShowDesktopButtonSize: function() { if (this._showDesktopButton) { let buttonSize = Me.settings.get_int('showdesktop-button-width') + 'px;'; - let isVertical = checkIfVertical(); + let isVertical = this.checkIfVertical(); let sytle = isVertical ? 'border-top-width:1px;height:' + buttonSize : 'border-left-width:1px;width:' + buttonSize; this._showDesktopButton.set_style(sytle); diff --git a/panelManager.js b/panelManager.js index 312a33f..f17a23d 100755 --- a/panelManager.js +++ b/panelManager.js @@ -93,8 +93,8 @@ var dtpPanelManager = Utils.defineClass({ global.dashToPanel.panels = this.allPanels; global.dashToPanel.emit('panels-created'); - let panelPosition = Panel.getPosition(); this.allPanels.forEach(p => { + let panelPosition = p.getPosition(); let leftOrRight = (panelPosition == St.Side.LEFT || panelPosition == St.Side.RIGHT); p.panelBox.set_size( @@ -121,7 +121,7 @@ var dtpPanelManager = Utils.defineClass({ this._updatePanelElementPositions(); this.setFocusedMonitor(this.dtpPrimaryMonitor); - if (Panel.checkIfVertical()) { + if (this.primaryPanel.checkIfVertical()) { Main.wm._getPositionForDirection = newGetPositionForDirection; } @@ -261,7 +261,7 @@ var dtpPanelManager = Utils.defineClass({ ); Panel.panelBoxes.forEach(c => this._signalsHandler.add( - [Main.panel[c], 'actor-added', (parent, child) => this._adjustPanelMenuButton(this._getPanelMenuButton(child), this.primaryPanel.monitor, Panel.getPosition())] + [Main.panel[c], 'actor-added', (parent, child) => this._adjustPanelMenuButton(this._getPanelMenuButton(child), this.primaryPanel.monitor, this.primaryPanel.getPosition())] )); this._setKeyBindings(true); @@ -429,7 +429,7 @@ var dtpPanelManager = Utils.defineClass({ }, _updatePanelElementPositions: function() { - this.panelsElementPositions = Pos.getSettingsPositions(Me.settings); + this.panelsElementPositions = Pos.getSettingsPositions(Me.settings, 'panel-element-positions'); this.allPanels.forEach(p => p.updateElementPositions()); }, @@ -452,7 +452,8 @@ var dtpPanelManager = Utils.defineClass({ _getBoxPointerPreferredHeight: function(boxPointer, alloc, monitor) { if (boxPointer._dtpInPanel && boxPointer.sourceActor && Me.settings.get_boolean('intellihide')) { monitor = monitor || Main.layoutManager.findMonitorForActor(boxPointer.sourceActor); - let excess = alloc.natural_size + Panel.size + 10 - monitor.height; // 10 is arbitrary + let panel = global.dashToPanel.panels.find(p => p.monitor == monitor); + let excess = alloc.natural_size + panel.dtpSize + 10 - monitor.height; // 10 is arbitrary if (excess > 0) { alloc.natural_size -= excess; @@ -676,11 +677,11 @@ function newUpdateHotCorners() { return; } - let panelPosition = Panel.getPosition(); - let panelTopLeft = panelPosition == St.Side.TOP || panelPosition == St.Side.LEFT; - // build new hot corners for (let i = 0; i < this.monitors.length; i++) { + let panel = global.dashToPanel.panels.find(p => p.monitor.index == i); + let panelPosition = panel.getPosition(); + let panelTopLeft = panelPosition == St.Side.TOP || panelPosition == St.Side.LEFT; let monitor = this.monitors[i]; let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x; let cornerY = monitor.y; @@ -724,7 +725,7 @@ function newUpdateHotCorners() { let corner = new Layout.HotCorner(this, monitor, cornerX, cornerY); corner.setBarrierSize = size => corner.__proto__.setBarrierSize.call(corner, Math.min(size, 32)); - corner.setBarrierSize(Panel.size); + corner.setBarrierSize(panel.dtpSize); this.hotCorners.push(corner); } else { this.hotCorners.push(null); @@ -757,7 +758,7 @@ function newUpdatePanelBarrier(panel) { let fixed1 = panel.monitor.y; let fixed2 = panel.monitor.y + barrierSize; - if (Panel.checkIfVertical()) { + if (panel.checkIfVertical()) { barriers._rightPanelBarrier.push(panel.monitor.y + panel.monitor.height, Meta.BarrierDirection.POSITIVE_Y); barriers._leftPanelBarrier.push(panel.monitor.y, Meta.BarrierDirection.NEGATIVE_Y); } else { @@ -765,7 +766,7 @@ function newUpdatePanelBarrier(panel) { barriers._leftPanelBarrier.push(panel.monitor.x, Meta.BarrierDirection.POSITIVE_X); } - switch (Panel.getPosition()) { + switch (panel.getPosition()) { //values are initialized as St.Side.TOP case St.Side.BOTTOM: fixed1 = panel.monitor.y + panel.monitor.height - barrierSize; @@ -798,16 +799,17 @@ function newUpdatePanelBarrier(panel) { directions: barriers[k][2] }; - barrierOptions[Panel.varCoord.c1] = barrierOptions[Panel.varCoord.c2] = barriers[k][1]; - barrierOptions[Panel.fixedCoord.c1] = fixed1; - barrierOptions[Panel.fixedCoord.c2] = fixed2; + barrierOptions[panel.varCoord.c1] = barrierOptions[panel.varCoord.c2] = barriers[k][1]; + barrierOptions[panel.fixedCoord.c1] = fixed1; + barrierOptions[panel.fixedCoord.c2] = fixed2; barriers[k][0][k] = new Meta.Barrier(barrierOptions); }); } function _newLookingGlassResize() { - let topOffset = Panel.getPosition() == St.Side.TOP ? Panel.size : 32; + let primaryMonitorPanel = global.dashToPanel.panels.find(p => p.monitor == Main.layoutManager.primaryMonitor); + let topOffset = primaryMonitorPanel.getPosition() == St.Side.TOP ? primaryMonitorPanel.size : 32; this._oldResize(); Utils.wrapActor(this); diff --git a/panelPositions.js b/panelPositions.js index b635803..5b98e06 100644 --- a/panelPositions.js +++ b/panelPositions.js @@ -47,11 +47,11 @@ var optionDialogFunctions = {}; optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions'; optionDialogFunctions[DESKTOP_BTN] = '_showDesktopButtonOptions'; -function getSettingsPositions(settings) { +function getSettingsPositions(settings, setting) { var positions = null; try { - positions = JSON.parse(settings.get_string('panel-element-positions')); + positions = JSON.parse(settings.get_string(setting)); } catch(e) { log('Error parsing positions: ' + e.message); } diff --git a/panelStyle.js b/panelStyle.js index 73e5072..2697ace 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -79,7 +79,7 @@ var dtpPanelStyle = Utils.defineClass({ this._rightBoxOperations = []; let trayPadding = Me.settings.get_int('tray-padding'); - let isVertical = Panel.checkIfVertical(); + let isVertical = this.panel.checkIfVertical(); let paddingStyle = 'padding: ' + (isVertical ? '%dpx 0' : '0 %dpx'); if(trayPadding >= 0) { diff --git a/prefs.js b/prefs.js index 5206154..11c02f1 100644 --- a/prefs.js +++ b/prefs.js @@ -216,7 +216,7 @@ const Settings = new Lang.Class({ let labels = {}; let position = this._settings.get_string('panel-position'); let isVertical = position == 'LEFT' || position == 'RIGHT'; - let positionSettings = Pos.getSettingsPositions(this._settings); + let positionSettings = Pos.getSettingsPositions(this._settings, 'panel-element-positions'); let panelInfo = positionSettings[monitorIndex] || Pos.defaults; let updateSettings = () => { let newPanelInfo = []; diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 61021a0..74c0671 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -77,6 +77,11 @@ Sync element positions Sync panel element positions on all monitors. + + '{}' + Panel positions + Panel positions (JSON). + '{}' Panel element positions diff --git a/taskbar.js b/taskbar.js index bdadcb8..2133198 100644 --- a/taskbar.js +++ b/taskbar.js @@ -80,24 +80,25 @@ var taskbarActor = Utils.defineClass({ this._delegate = delegate; this._currentBackgroundColor = 0; this.callParent('_init', { name: 'dashtopanelTaskbar', - layout_manager: new Clutter.BoxLayout({ orientation: Clutter.Orientation[Panel.getOrientation().toUpperCase()] }), + layout_manager: new Clutter.BoxLayout({ orientation: Clutter.Orientation[delegate.dtpPanel.getOrientation().toUpperCase()] }), clip_to_allocation: true }); }, vfunc_allocate: function(box, flags)  { this.set_allocation(box, flags); - let availFixedSize = box[Panel.fixedCoord.c2] - box[Panel.fixedCoord.c1]; - let availVarSize = box[Panel.varCoord.c2] - box[Panel.varCoord.c1]; + let panel = this._delegate.dtpPanel; + let availFixedSize = box[panel.fixedCoord.c2] - box[panel.fixedCoord.c1]; + let availVarSize = box[panel.varCoord.c2] - box[panel.varCoord.c1]; let [, scrollview, leftFade, rightFade] = this.get_children(); - let [, natSize] = this[Panel.sizeFunc](availFixedSize); + let [, natSize] = this[panel.sizeFunc](availFixedSize); let childBox = new Clutter.ActorBox(); - let orientation = Panel.getOrientation(); + let orientation = panel.getOrientation(); - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1]; - childBox[Panel.varCoord.c2] = Math.min(availVarSize, natSize); - childBox[Panel.fixedCoord.c1] = box[Panel.fixedCoord.c1]; - childBox[Panel.fixedCoord.c2] = box[Panel.fixedCoord.c2]; + childBox[panel.varCoord.c1] = box[panel.varCoord.c1]; + childBox[panel.varCoord.c2] = Math.min(availVarSize, natSize); + childBox[panel.fixedCoord.c1] = box[panel.fixedCoord.c1]; + childBox[panel.fixedCoord.c2] = box[panel.fixedCoord.c2]; scrollview.allocate(childBox, flags); @@ -105,8 +106,8 @@ var taskbarActor = Utils.defineClass({ upper = Math.floor(upper); scrollview._dtpFadeSize = upper > pageSize ? this._delegate.iconSize : 0; - if (this._currentBackgroundColor !== this._delegate.dtpPanel.dynamicTransparency.currentBackgroundColor) { - this._currentBackgroundColor = this._delegate.dtpPanel.dynamicTransparency.currentBackgroundColor; + if (this._currentBackgroundColor !== panel.dynamicTransparency.currentBackgroundColor) { + this._currentBackgroundColor = panel.dynamicTransparency.currentBackgroundColor; let gradientStyle = 'background-gradient-start: ' + this._currentBackgroundColor + 'background-gradient-direction: ' + orientation; @@ -114,11 +115,11 @@ var taskbarActor = Utils.defineClass({ rightFade.set_style(gradientStyle); } - childBox[Panel.varCoord.c2] = childBox[Panel.varCoord.c1] + (value > 0 ? scrollview._dtpFadeSize : 0); + childBox[panel.varCoord.c2] = childBox[panel.varCoord.c1] + (value > 0 ? scrollview._dtpFadeSize : 0); leftFade.allocate(childBox, flags); - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c2] - (value + pageSize < upper ? scrollview._dtpFadeSize : 0); - childBox[Panel.varCoord.c2] = box[Panel.varCoord.c2]; + childBox[panel.varCoord.c1] = box[panel.varCoord.c2] - (value + pageSize < upper ? scrollview._dtpFadeSize : 0); + childBox[panel.varCoord.c2] = box[panel.varCoord.c2]; rightFade.allocate(childBox, flags); }, @@ -171,7 +172,7 @@ var taskbar = Utils.defineClass({ this._labelShowing = false; this.fullScrollView = 0; - let isVertical = Panel.checkIfVertical(); + let isVertical = panel.checkIfVertical(); this._box = new St.BoxLayout({ vertical: isVertical, clip_to_allocation: false, @@ -210,7 +211,7 @@ var taskbar = Utils.defineClass({ this._container.add_child(new St.Widget({ width: 0, reactive: false })); this._container.add_actor(this._scrollView); - let orientation = Panel.getOrientation(); + let orientation = panel.getOrientation(); let fadeStyle = 'background-gradient-direction:' + orientation; let fade1 = new St.Widget({ style_class: 'scrollview-fade', reactive: false }); let fade2 = new St.Widget({ style_class: 'scrollview-fade', @@ -378,7 +379,7 @@ var taskbar = Utils.defineClass({ _onScrollEvent: function(actor, event) { - let orientation = Panel.getOrientation(); + let orientation = this.dtpPanel.getOrientation(); // reset timeout to avid conflicts with the mousehover event if (this._ensureAppIconVisibilityTimeoutId>0) { @@ -427,7 +428,7 @@ var taskbar = Utils.defineClass({ // force a fixed label width to prevent the icons from "wiggling" when an animation runs // (adding or removing an icon). When the taskbar is full, revert to a dynamic label width // to allow them to resize and make room for new icons. - if (!Panel.checkIfVertical() && !this.isGroupApps) { + if (!this.dtpPanel.checkIfVertical() && !this.isGroupApps) { let initial = this.fullScrollView; if (!this.fullScrollView && Math.floor(adjustment.upper) > adjustment.page_size) { @@ -584,6 +585,7 @@ var taskbar = Utils.defineClass({ let item = new Dash.DashItemContainer(); + item._dtpPanel = this.dtpPanel extendDashItemContainer(item); item.setChild(appIcon.actor); @@ -905,7 +907,7 @@ var taskbar = Utils.defineClass({ this._shownInitially = false; this._redisplay(); - if (geometryChange && Panel.checkIfVertical()) { + if (geometryChange && this.dtpPanel.checkIfVertical()) { this.previewMenu._updateClip(); } }, @@ -968,7 +970,7 @@ var taskbar = Utils.defineClass({ this._box.insert_child_above(source._dashItemContainer, null); } - let isVertical = Panel.checkIfVertical(); + let isVertical = this.dtpPanel.checkIfVertical(); let sizeProp = isVertical ? 'height' : 'width'; let posProp = isVertical ? 'y' : 'x'; let pos = isVertical ? y : x; @@ -1242,7 +1244,7 @@ var DragPlaceholderItem = Utils.defineClass({ Extends: St.Widget, _init: function(appIcon, iconSize) { - this.callParent('_init', { style: AppIcons.getIconContainerStyle(), layout_manager: new Clutter.BinLayout() }); + this.callParent('_init', { style: appIcon.getIconContainerStyle(), layout_manager: new Clutter.BinLayout() }); this.child = { _delegate: appIcon }; diff --git a/transparency.js b/transparency.js index 835f88a..aa86d7a 100644 --- a/transparency.js +++ b/transparency.js @@ -134,7 +134,7 @@ var DynamicTransparency = Utils.defineClass({ this._proximityManager.removeWatch(this._proximityWatchId); if (Me.settings.get_boolean('trans-use-dynamic-opacity')) { - let isVertical = Panel.checkIfVertical(); + let isVertical = this._dtpPanel.checkIfVertical(); let threshold = Me.settings.get_int('trans-dynamic-distance'); this._proximityWatchId = this._proximityManager.createWatch( @@ -206,7 +206,7 @@ var DynamicTransparency = Utils.defineClass({ this._gradientStyle = ''; if (Me.settings.get_boolean('trans-use-custom-gradient')) { - this._gradientStyle += 'background-gradient-direction: ' + (Panel.checkIfVertical() ? 'horizontal;' : 'vertical;') + + this._gradientStyle += 'background-gradient-direction: ' + (this._dtpPanel.checkIfVertical() ? 'horizontal;' : 'vertical;') + 'background-gradient-start: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-top-color'), Me.settings.get_double('trans-gradient-top-opacity')) + 'background-gradient-end: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-bottom-color'), diff --git a/windowPreview.js b/windowPreview.js index 2cad787..b8a4dff 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -53,7 +53,6 @@ const FADE_SIZE = 36; const PEEK_INDEX_PROP = '_dtpPeekInitialIndex'; let headerHeight = 0; -let clipHeight = 0; let alphaBg = 0; let isLeftButtons = false; let isTopHeader = true; @@ -80,7 +79,7 @@ var PreviewMenu = Utils.defineClass({ this.isVertical = geom.position == St.Side.LEFT || geom.position == St.Side.RIGHT; this._translationProp = 'translation_' + (this.isVertical ? 'x' : 'y'); this._translationDirection = (geom.position == St.Side.TOP || geom.position == St.Side.LEFT ? -1 : 1); - this._translationOffset = Math.min(Panel.size, MAX_TRANSLATION) * this._translationDirection; + this._translationOffset = Math.min(panel.dtpSize, MAX_TRANSLATION) * this._translationDirection; this.menu = new St.Widget({ name: 'preview-menu', @@ -192,7 +191,7 @@ var PreviewMenu = Utils.defineClass({ if (!this.opened) { this._refreshGlobals(); - this.set_height(clipHeight); + this.set_height(this.clipHeight); this.menu.show(); setStyle(this.menu, 'background: ' + Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, alphaBg)); @@ -442,25 +441,25 @@ var PreviewMenu = Utils.defineClass({ if (this.isVertical) { w = previewSize; - clipHeight = this.panel.monitor.height; + this.clipHeight = this.panel.monitor.height; y = this.panel.monitor.y; } else { w = this.panel.monitor.width; - clipHeight = (previewSize + headerHeight); + this.clipHeight = (previewSize + headerHeight); x = this.panel.monitor.x; } if (geom.position == St.Side.LEFT) { - x = this.panel.monitor.x + Panel.size + panelBoxTheme.get_padding(St.Side.LEFT); + x = this.panel.monitor.x + this.panel.dtpSize + panelBoxTheme.get_padding(St.Side.LEFT); } else if (geom.position == St.Side.RIGHT) { - x = this.panel.monitor.x + this.panel.monitor.width - (Panel.size + previewSize) - panelBoxTheme.get_padding(St.Side.RIGHT); + x = this.panel.monitor.x + this.panel.monitor.width - (this.panel.dtpSize + previewSize) - panelBoxTheme.get_padding(St.Side.RIGHT); } else if (geom.position == St.Side.TOP) { - y = this.panel.monitor.y + Panel.size + panelBoxTheme.get_padding(St.Side.TOP); + y = this.panel.monitor.y + this.panel.dtpSize + panelBoxTheme.get_padding(St.Side.TOP); } else { //St.Side.BOTTOM - y = this.panel.monitor.y + this.panel.monitor.height - (Panel.size + panelBoxTheme.get_padding(St.Side.BOTTOM) + previewSize + headerHeight); + y = this.panel.monitor.y + this.panel.monitor.height - (this.panel.dtpSize + panelBoxTheme.get_padding(St.Side.BOTTOM) + previewSize + headerHeight); } - Utils.setClip(this, x, y, w, clipHeight); + Utils.setClip(this, x, y, w, this.clipHeight); }, _updatePosition: function() { @@ -526,7 +525,7 @@ var PreviewMenu = Utils.defineClass({ let endBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, 0) let fadeStyle = 'background-gradient-start:' + startBg + 'background-gradient-end:' + endBg + - 'background-gradient-direction:' + Panel.getOrientation(); + 'background-gradient-direction:' + this.panel.getOrientation(); if (this.isVertical) { y = end ? this.panel.monitor.height - FADE_SIZE : 0; From c2f77976423e88a43b211392d21d827bb1936ce9 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 14 Jun 2020 15:28:49 -0400 Subject: [PATCH 19/21] Add settings to handle per panel positioning --- Settings.ui | 137 ++++++++++++++------------------- panel.js | 17 ++--- panelManager.js | 3 +- panelPositions.js | 5 ++ prefs.js | 189 +++++++++++++++++++++++++--------------------- 5 files changed, 172 insertions(+), 179 deletions(-) diff --git a/Settings.ui b/Settings.ui index cbbad32..21504b0 100644 --- a/Settings.ui +++ b/Settings.ui @@ -4333,29 +4333,68 @@ vertical 24 - + True False 0 in - + True False - none + vertical - - 100 + True - True + False + 12 + 12 + 12 + 12 + + + True + False + True + Order and positions on monitor + 0 + + + 0 + 0 + + + + + True + False + center + + + 1 + 0 + + + + + Apply changes to all monitors + True + True + False + 12 + True + + + 0 + 1 + + True False - 12 - 12 - 12 - 12 + 18 + 6 32 @@ -4387,7 +4426,7 @@ 0 True True - + False @@ -4407,7 +4446,7 @@ bottom True position_bottom_button - + False @@ -4427,7 +4466,7 @@ bottom True position_bottom_button - + False @@ -4447,7 +4486,7 @@ bottom True position_bottom_button - + False @@ -4463,76 +4502,10 @@ - - - - - - - - - - - False - True - 0 - - - - - True - False - 0 - in - - - True - False - vertical - - - True - False - 12 - 12 - 12 - 12 - - - True - False - True - Order and position of panel elements on monitor - 0 - 0 - 0 - - - - - True - False - center - - - 1 - 0 - - - - - Apply position changes to all monitors - True - True - False - 12 - True - - - 0 - 1 + 2 + 2 diff --git a/panel.js b/panel.js index e2dba2a..3c1ee4c 100644 --- a/panel.js +++ b/panel.js @@ -91,8 +91,6 @@ var dtpPanel = Utils.defineClass({ Extends: St.Widget, _init: function(panelManager, monitor, panelBox, isStandalone) { - let position = this.getPosition(); - this.callParent('_init', { layout_manager: new Clutter.BinLayout() }); this._timeoutsHandler = new Utils.TimeoutsHandler(); @@ -116,6 +114,8 @@ var dtpPanel = Utils.defineClass({ this._elementGroups = []; this.cornerSize = 0; + let position = this.getPosition(); + if (isStandalone) { this.panel = new dtpSecondaryPanel({ name: 'panel', reactive: true }); this.statusArea = this.panel.statusArea = {}; @@ -521,13 +521,14 @@ var dtpPanel = Utils.defineClass({ }, getPosition: function() { - let position = Me.settings.get_string('panel-position'); + //for now, use the previous "global" position setting as default. The 'panel-position' should be deleted in the future + let position = this.panelManager.panelPositions[this.monitor.index] || Me.settings.get_string('panel-position'); - if (position == 'TOP') { + if (position == Pos.TOP) { return St.Side.TOP; - } else if (position == 'RIGHT') { + } else if (position == Pos.RIGHT) { return St.Side.RIGHT; - } else if (position == 'BOTTOM') { + } else if (position == Pos.BOTTOM) { return St.Side.BOTTOM; } @@ -623,10 +624,6 @@ var dtpPanel = Utils.defineClass({ }); }, - _getElementPositions: function() { - return this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; - }, - _disablePanelCornerSignals: function() { if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); diff --git a/panelManager.js b/panelManager.js index f17a23d..f62c867 100755 --- a/panelManager.js +++ b/panelManager.js @@ -73,6 +73,7 @@ var dtpPanelManager = Utils.defineClass({ enable: function(reset) { let dtpPrimaryIndex = Me.settings.get_int('primary-monitor'); + this.panelPositions = Pos.getSettingsPositions(Me.settings, 'panel-positions'); this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor; this.proximityManager = new Proximity.ProximityManager(); @@ -233,7 +234,7 @@ var dtpPanelManager = Utils.defineClass({ 'changed::primary-monitor', 'changed::multi-monitors', 'changed::isolate-monitors', - 'changed::panel-position', + 'changed::panel-positions', 'changed::stockgs-keep-top-panel' ], () => this._reset() diff --git a/panelPositions.js b/panelPositions.js index 5b98e06..3c2d1af 100644 --- a/panelPositions.js +++ b/panelPositions.js @@ -30,6 +30,11 @@ var STACKED_BR = 'stackedBR'; var CENTERED = 'centered'; var CENTERED_MONITOR = 'centerMonitor'; +var TOP = 'TOP'; +var BOTTOM = 'BOTTOM'; +var LEFT = 'LEFT'; +var RIGHT = 'RIGHT'; + var defaults = [ { element: SHOW_APPS_BTN, visible: true, position: STACKED_TL }, { element: ACTIVITIES_BTN, visible: false, position: STACKED_TL }, diff --git a/prefs.js b/prefs.js index 11c02f1..37e2551 100644 --- a/prefs.js +++ b/prefs.js @@ -199,42 +199,97 @@ const Settings = new Lang.Class({ }, _updateVerticalRelatedOptions: function() { - let position = this._settings.get_string('panel-position'); - let isVertical = position == 'LEFT' || position == 'RIGHT'; + let position = this._getPanelPosition(this._currentMonitorIndex); + let isVertical = position == Pos.LEFT || position == Pos.RIGHT; let showDesktopWidthLabel = this._builder.get_object('show_showdesktop_width_label'); showDesktopWidthLabel.set_text(isVertical ? _('Show Desktop button height (px)') : _('Show Desktop button width (px)')); - this._displayTaskbarElementPositionsForMonitor(this.monitors[this._builder.get_object('taskbar_position_monitor_combo').get_active()]); + this._displayPanelPositionsForMonitor(this._currentMonitorIndex); }, - _displayTaskbarElementPositionsForMonitor: function(monitorIndex) { + _maybeDisableTopPosition: function() { + let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel'); + let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); + let topAvailable = !keepTopPanel || (!monitorSync && this._currentMonitorIndex != this.monitors[0]); + let topRadio = this._builder.get_object('position_top_button'); + + topRadio.set_sensitive(topAvailable); + topRadio.set_tooltip_text(!topAvailable ? _('Unavailable when gnome-shell top panel is present') : ''); + }, + + _getPanelPositions: function() { + return Pos.getSettingsPositions(this._settings, 'panel-positions'); + }, + + _getPanelPosition: function(monitorIndex) { + let panelPositionsSettings = this._getPanelPositions(); + + return panelPositionsSettings[monitorIndex] || this._settings.get_string('panel-position'); + }, + + _setPanelPosition: function(position) { + let panelPositionsSettings = this._getPanelPositions(); + let preventTop = this._settings.get_boolean('stockgs-keep-top-panel') && position == Pos.TOP; + let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); + let monitors = monitorSync ? this.monitors : [this._currentMonitorIndex]; + + monitors.forEach(m => panelPositionsSettings[m] = preventTop && this.monitors[0] == m ? Pos.BOTTOM : position); + + this._settings.set_string('panel-positions', JSON.stringify(panelPositionsSettings)); + }, + + _setPositionRadios: function(position) { + this._ignorePositionRadios = true; + + switch (position) { + case Pos.BOTTOM: + this._builder.get_object('position_bottom_button').set_active(true); + break; + case Pos.TOP: + this._builder.get_object('position_top_button').set_active(true); + break; + case Pos.LEFT: + this._builder.get_object('position_left_button').set_active(true); + break; + case Pos.RIGHT: + this._builder.get_object('position_right_button').set_active(true); + break; + } + + this._ignorePositionRadios = false; + }, + + _displayPanelPositionsForMonitor: function(monitorIndex) { let taskbarListBox = this._builder.get_object('taskbar_display_listbox'); taskbarListBox.get_children().forEach(c => c.destroy()); let labels = {}; - let position = this._settings.get_string('panel-position'); - let isVertical = position == 'LEFT' || position == 'RIGHT'; - let positionSettings = Pos.getSettingsPositions(this._settings, 'panel-element-positions'); - let panelInfo = positionSettings[monitorIndex] || Pos.defaults; - let updateSettings = () => { - let newPanelInfo = []; + let panelPosition = this._getPanelPosition(monitorIndex); + let isVertical = panelPosition == Pos.LEFT || panelPosition == Pos.RIGHT; + let panelElementPositionsSettings = Pos.getSettingsPositions(this._settings, 'panel-element-positions'); + let panelElementPositions = panelElementPositionsSettings[monitorIndex] || Pos.defaults; + let updateElementsSettings = () => { + let newPanelElementPositions = []; let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); let monitors = monitorSync ? this.monitors : [monitorIndex]; taskbarListBox.get_children().forEach(c => { - newPanelInfo.push({ + newPanelElementPositions.push({ element: c.id, visible: c.visibleToggleBtn.get_active(), position: c.positionCombo.get_active_id() }); }); - monitors.forEach(m => positionSettings[m] = newPanelInfo); - this._settings.set_string('panel-element-positions', JSON.stringify(positionSettings)); + monitors.forEach(m => panelElementPositionsSettings[m] = newPanelElementPositions); + this._settings.set_string('panel-element-positions', JSON.stringify(panelElementPositionsSettings)); }; + this._maybeDisableTopPosition(); + this._setPositionRadios(panelPosition); + labels[Pos.SHOW_APPS_BTN] = _('Show Applications button'); labels[Pos.ACTIVITIES_BTN] = _('Activities button'); labels[Pos.TASKBAR] = _('Taskbar'); @@ -245,7 +300,7 @@ const Settings = new Lang.Class({ labels[Pos.RIGHT_BOX] = _('Right box'); labels[Pos.DESKTOP_BTN] = _('Desktop button'); - panelInfo.forEach(el => { + panelElementPositions.forEach(el => { let row = new Gtk.ListBoxRow(); let grid = new Gtk.Grid({ margin: 2, margin_left: 12, margin_right: 12, column_spacing: 8 }); let upDownGrid = new Gtk.Grid({ column_spacing: 2 }); @@ -261,7 +316,7 @@ const Settings = new Lang.Class({ if (index != limit) { taskbarListBox.remove(row); taskbarListBox.insert(row, index + (!limit ? -1 : 1)); - updateSettings(); + updateElementsSettings(); } }; @@ -272,9 +327,9 @@ const Settings = new Lang.Class({ positionCombo.set_active_id(el.position); upBtn.connect('clicked', () => upDownClickHandler(0)); - downBtn.connect('clicked', () => upDownClickHandler(panelInfo.length - 1)); - visibleToggleBtn.connect('toggled', () => updateSettings()); - positionCombo.connect('changed', () => updateSettings()); + downBtn.connect('clicked', () => upDownClickHandler(panelElementPositions.length - 1)); + visibleToggleBtn.connect('toggled', () => updateElementsSettings()); + positionCombo.connect('changed', () => updateElementsSettings()); upBtn.add(upImg); downBtn.add(downImg); @@ -419,37 +474,7 @@ const Settings = new Lang.Class({ dialog.show_all(); }, - _setPositionRadios: function() { - let position = this._settings.get_string('panel-position'); - - switch (position) { - case 'BOTTOM': - this._builder.get_object('position_bottom_button').set_active(true); - break; - case 'TOP': - this._builder.get_object('position_top_button').set_active(true); - break; - case 'LEFT': - this._builder.get_object('position_left_button').set_active(true); - break; - case 'RIGHT': - this._builder.get_object('position_right_button').set_active(true); - break; - - } - }, - _bindSettings: function() { - // Position and style panel - - // Position option - this._setPositionRadios(); - - this.monitors = this._settings.get_value('available-monitors').deep_unpack(); - - this._settings.connect('changed::panel-position', () => this._updateVerticalRelatedOptions()); - this._updateVerticalRelatedOptions(); - // size options let panel_size_scale = this._builder.get_object('panel_size_scale'); panel_size_scale.set_range(DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length-1], DEFAULT_PANEL_SIZES[0]); @@ -689,6 +714,18 @@ const Settings = new Lang.Class({ })); //multi-monitor + this.monitors = this._settings.get_value('available-monitors').deep_unpack(); + + let dtpPrimaryMonitorIndex = this.monitors.indexOf(this._settings.get_int('primary-monitor')); + + if (dtpPrimaryMonitorIndex < 0) { + dtpPrimaryMonitorIndex = 0; + } + + this._currentMonitorIndex = this.monitors[dtpPrimaryMonitorIndex]; + + this._settings.connect('changed::panel-positions', () => this._updateVerticalRelatedOptions()); + this._updateVerticalRelatedOptions(); for (let i = 0; i < this.monitors.length; ++i) { //the primary index is the first one in the "available-monitors" setting @@ -697,13 +734,7 @@ const Settings = new Lang.Class({ this._builder.get_object('multimon_primary_combo').append_text(label); this._builder.get_object('taskbar_position_monitor_combo').append_text(label); } - - let dtpPrimaryMonitorIndex = this.monitors.indexOf(this._settings.get_int('primary-monitor')); - - if (dtpPrimaryMonitorIndex < 0) { - dtpPrimaryMonitorIndex = 0; - } - + this._builder.get_object('multimon_primary_combo').set_active(dtpPrimaryMonitorIndex); this._builder.get_object('taskbar_position_monitor_combo').set_active(dtpPrimaryMonitorIndex); @@ -717,16 +748,19 @@ const Settings = new Lang.Class({ 'sensitive', Gio.SettingsBindFlags.INVERT_BOOLEAN); + this._settings.connect('changed::panel-element-positions-monitors-sync', () => this._maybeDisableTopPosition()); + this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) { this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]); })); this._builder.get_object('taskbar_position_monitor_combo').connect('changed', Lang.bind (this, function(widget) { - this._displayTaskbarElementPositionsForMonitor(this.monitors[widget.get_active()]); + this._currentMonitorIndex = this.monitors[widget.get_active()]; + this._displayPanelPositionsForMonitor(this._currentMonitorIndex); })); - //taskbar element positions - this._displayTaskbarElementPositionsForMonitor(this.monitors[this._builder.get_object('multimon_primary_combo').get_active()]); + //panel positions + this._displayPanelPositionsForMonitor(this._currentMonitorIndex); this._settings.bind('multi-monitors', this._builder.get_object('multimon_multi_switch'), @@ -1811,24 +1845,11 @@ const Settings = new Lang.Class({ 'active', Gio.SettingsBindFlags.DEFAULT); - var maybeDisableTopPosition = () => { - let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel'); - let topRadio = this._builder.get_object('position_top_button'); - - topRadio.set_sensitive(!keepTopPanel); - topRadio.set_tooltip_text(keepTopPanel ? _('Unavailable when gnome-shell top panel is present') : ''); - - if (keepTopPanel && this._settings.get_string('panel-position') == 'TOP') { - this._settings.set_string('panel-position', "BOTTOM"); - this._setPositionRadios(); - } - }; + - this._settings.connect('changed::stockgs-keep-top-panel', () => { - maybeDisableTopPosition(); - }); + this._settings.connect('changed::stockgs-keep-top-panel', () => this._maybeDisableTopPosition()); - maybeDisableTopPosition(); + this._maybeDisableTopPosition(); this._settings.bind('stockgs-panelbtn-click-only', this._builder.get_object('stockgs_panelbtn_switch'), @@ -1942,24 +1963,20 @@ const Settings = new Lang.Class({ */ _SignalHandler: { - position_bottom_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "BOTTOM"); + position_bottom_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.BOTTOM); }, - position_top_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "TOP"); + position_top_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.TOP); }, - position_left_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "LEFT"); + position_left_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.LEFT); }, - position_right_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "RIGHT"); + position_right_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.RIGHT); }, dots_bottom_button_toggled_cb: function(button) { From 4a6f27ac7b4d7487fa0a324afadbe5c65e4b070d Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 14 Jun 2020 19:20:23 -0400 Subject: [PATCH 20/21] Add array find for older gnome-shell versions --- panel.js | 2 +- panelManager.js | 6 +++--- utils.js | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/panel.js b/panel.js index 3c1ee4c..37c4b9a 100644 --- a/panel.js +++ b/panel.js @@ -1106,7 +1106,7 @@ var dtpPanel = Utils.defineClass({ workspace.list_windows() ).reverse(); - return allWindowsByStacking.find(metaWindow => { + return Utils.find(allWindowsByStacking, metaWindow => { let rect = metaWindow.get_frame_rect(); return metaWindow.get_monitor() == this.monitor.index && diff --git a/panelManager.js b/panelManager.js index f62c867..046ce2f 100755 --- a/panelManager.js +++ b/panelManager.js @@ -453,7 +453,7 @@ var dtpPanelManager = Utils.defineClass({ _getBoxPointerPreferredHeight: function(boxPointer, alloc, monitor) { if (boxPointer._dtpInPanel && boxPointer.sourceActor && Me.settings.get_boolean('intellihide')) { monitor = monitor || Main.layoutManager.findMonitorForActor(boxPointer.sourceActor); - let panel = global.dashToPanel.panels.find(p => p.monitor == monitor); + let panel = Utils.find(global.dashToPanel.panels, p => p.monitor == monitor); let excess = alloc.natural_size + panel.dtpSize + 10 - monitor.height; // 10 is arbitrary if (excess > 0) { @@ -680,7 +680,7 @@ function newUpdateHotCorners() { // build new hot corners for (let i = 0; i < this.monitors.length; i++) { - let panel = global.dashToPanel.panels.find(p => p.monitor.index == i); + let panel = Utils.find(global.dashToPanel.panels, p => p.monitor.index == i); let panelPosition = panel.getPosition(); let panelTopLeft = panelPosition == St.Side.TOP || panelPosition == St.Side.LEFT; let monitor = this.monitors[i]; @@ -809,7 +809,7 @@ function newUpdatePanelBarrier(panel) { } function _newLookingGlassResize() { - let primaryMonitorPanel = global.dashToPanel.panels.find(p => p.monitor == Main.layoutManager.primaryMonitor); + let primaryMonitorPanel = Utils.find(global.dashToPanel.panels, p => p.monitor == Main.layoutManager.primaryMonitor); let topOffset = primaryMonitorPanel.getPosition() == St.Side.TOP ? primaryMonitorPanel.size : 32; this._oldResize(); diff --git a/utils.js b/utils.js index 8fbb280..73486cf 100644 --- a/utils.js +++ b/utils.js @@ -316,6 +316,14 @@ var findIndex = function(array, predicate) { return -1; }; +var find = function(array, predicate) { + let index = findIndex(array, predicate); + + if (index > -1) { + return array[index]; + } +}; + var mergeObjects = function(main, bck) { for (var prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { From b06dcd0cfb1a960b6bfecfd6f38f96ededf3e40a Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Sun, 14 Jun 2020 20:14:10 -0400 Subject: [PATCH 21/21] Reorder settings position tab --- Settings.ui | 464 ++++++++++++++++++++++++++-------------------------- 1 file changed, 232 insertions(+), 232 deletions(-) diff --git a/Settings.ui b/Settings.ui index 21504b0..6351567 100644 --- a/Settings.ui +++ b/Settings.ui @@ -4332,6 +4332,238 @@ 24 vertical 24 + + + True + False + 0 + in + + + True + False + none + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + 32 + + + True + False + True + Display the main panel on + 0 + + + 0 + 0 + + + + + True + False + center + + + 1 + 0 + + + + + + + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 6 + 32 + + + True + False + True + Display panels on all monitors + True + 0 + + + 0 + 0 + + + + + True + True + end + center + + + 1 + 0 + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + 0 + in + + + True + False + none + + + 100 + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Panel Intellihide + True + 0 + + + 0 + 0 + + + + + True + False + 6 + + + True + True + True + center + center + 0.46000000834465027 + + + True + False + emblem-system-symbolic + + + + + + False + True + 0 + + + + + True + True + end + center + + + False + True + 1 + + + + + 1 + 0 + 2 + + + + + True + False + True + Hide and reveal the panel according to preferences + True + 40 + 0 + + + + 0 + 1 + + + + + + + + + + + + + + False + True + 1 + + True @@ -4543,238 +4775,6 @@ 2 - - - True - False - 0 - in - - - True - False - none - - - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - 32 - - - True - False - True - Display the main panel on - 0 - - - 0 - 0 - - - - - True - False - center - - - 1 - 0 - - - - - - - - - True - True - - - True - False - 12 - 12 - 12 - 12 - 6 - 32 - - - True - False - True - Display panels on all monitors - True - 0 - - - 0 - 0 - - - - - True - True - end - center - - - 1 - 0 - - - - - - - - - - - - - - False - True - 3 - - - - - True - False - 0 - in - - - True - False - none - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Panel Intellihide - True - 0 - - - 0 - 0 - - - - - True - False - 6 - - - True - True - True - center - center - 0.46000000834465027 - - - True - False - emblem-system-symbolic - - - - - - False - True - 0 - - - - - True - True - end - center - - - False - True - 1 - - - - - 1 - 0 - 2 - - - - - True - False - True - Hide and reveal the panel according to preferences - True - 40 - 0 - - - - 0 - 1 - - - - - - - - - - - - - - False - True - 4 - -