From 41e60c29f6b9b699eae7c24f853c6ab632065aff Mon Sep 17 00:00:00 2001 From: fredcw Date: Tue, 6 Aug 2024 04:00:02 +0100 Subject: [PATCH 1/2] GWL applet: Improve code readability Rename some variables Rename appList.js > workspace.js --- .../appGroup.js | 44 +-- .../applet.js | 289 +++++++++--------- .../grouped-window-list@cinnamon.org/menus.js | 4 +- .../settings-schema.json | 155 +++++----- .../{appList.js => workspace.js} | 138 +++++---- 5 files changed, 312 insertions(+), 318 deletions(-) rename files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/{appList.js => workspace.js} (75%) diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js index f8ffd5dca1..3e78967bf5 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js @@ -62,7 +62,7 @@ const getFocusState = function(metaWindow) { class AppGroup { constructor(params) { this.state = params.state; - this.listState = params.listState; + this.workspaceState = params.workspaceState; this.groupState = createStore({ app: params.app, appId: params.appId, @@ -254,10 +254,10 @@ class AppGroup { } setMargin() { - const applet = this.state.appletActor; + const appletActor = this.state.appletActor; const direction = this.state.isHorizontal ? 'right' : 'bottom'; const existingStyle = this.actor.style ? this.actor.style : ''; - let spacing = parseInt(applet.get_theme_node().get_length('spacing')); + let spacing = parseInt(appletActor.get_theme_node().get_length('spacing')); if (!spacing) { spacing = 6; } @@ -346,7 +346,7 @@ class AppGroup { const allocateForLabel = this.labelVisiblePref || (this.state.settings.titleDisplay == TitleDisplay.Focused && - this.listState.lastFocusedApp === appId); + this.workspaceState.lastFocusedApp === appId); if (this.state.orientation === St.Side.TOP || this.state.orientation === St.Side.BOTTOM) { if (allocateForLabel) { @@ -581,13 +581,13 @@ class AppGroup { const {appId, metaWindows, lastFocused} = this.groupState; if (hasFocus === undefined) { - hasFocus = this.listState.lastFocusedApp === appId; + hasFocus = this.workspaceState.lastFocusedApp === appId; } // If any of the windows associated with our app have focus, // we should set ourselves to active if (hasFocus) { - this.listState.trigger('updateFocusState', appId); + this.workspaceState.trigger('updateFocusState', appId); this.actor.add_style_pseudo_class('focus'); this.actor.remove_style_class_name('grouped-window-list-item-demands-attention'); if (this.hoverMenu) { @@ -609,9 +609,9 @@ class AppGroup { if (!this.groupState || !this.groupState.groupReady || this.groupState.willUnmount) { return; } - const windows = this.groupState.metaWindows; - for (let i = 0, len = windows.length; i < len; i++) { - if (windows[i] === metaWindow && !getFocusState(windows[i])) { + + this.groupState.metaWindows.forEach( window => { + if (window === metaWindow && !getFocusState(window)) { // Even though this may not be the last focused window, we want it to be // the window that gets focused when a user responds to an alert. this.groupState.set({lastFocused: metaWindow}); @@ -619,7 +619,7 @@ class AppGroup { this.getAttention(); return true; } - } + }); return false; } @@ -654,7 +654,7 @@ class AppGroup { Main.activateWindow(this.groupState.lastFocused, global.get_current_time()); } else { if (this.groupState.fileDrag) { - this.listState.trigger('closeAllHoverMenus'); + this.workspaceState.trigger('closeAllHoverMenus'); } // Open the thumbnail menu and activate the window corresponding to the dragged over thumbnail. if (!this.hoverMenu) this.initThumbnailMenu(); @@ -800,13 +800,13 @@ class AppGroup { } else if (button === 3) { if (!this.rightClickMenu) this.initRightClickMenu(); if (!this.rightClickMenu.isOpen) { - this.listState.trigger('closeAllRightClickMenus', () => { - this.listState.trigger('closeAllHoverMenus', () => { + this.workspaceState.trigger('closeAllRightClickMenus', () => { + this.workspaceState.trigger('closeAllHoverMenus', () => { this.rightClickMenu.toggle(); }); }); } else { - this.listState.trigger('closeAllRightClickMenus', this.listState.trigger('closeAllHoverMenus')); + this.workspaceState.trigger('closeAllRightClickMenus', this.workspaceState.trigger('closeAllHoverMenus')); } } if (this.hoverMenu) this.hoverMenu.onButtonPress(); @@ -833,7 +833,7 @@ class AppGroup { if (!this.hoverMenu) this.initThumbnailMenu(); this.hoverMenu.open(true); } else { - this.listState.trigger('closeAllHoverMenus'); + this.workspaceState.trigger('closeAllHoverMenus'); } this.windowHandle(); this.appKeyTimeout = setTimeout(() => { @@ -948,7 +948,7 @@ class AppGroup { this.calcWindowNumber(); } else { // This is the last window, so this group needs to be destroyed. We'll call back windowRemoved - // in appList to put the final nail in the coffin. + // in workspace to put the final nail in the coffin. if (typeof cb === 'function') { if (this.hoverMenu && this.groupState.isFavoriteApp) { this.groupState.trigger('removeThumbnailFromMenu', metaWindow); @@ -959,10 +959,10 @@ class AppGroup { } onAppChange(metaWindow) { - if (!this.listState) return; + if (!this.workspaceState) return; - this.listState.trigger('windowRemoved', metaWindow); - this.listState.trigger('windowAdded', metaWindow); + this.workspaceState.trigger('windowRemoved', metaWindow); + this.workspaceState.trigger('windowAdded', metaWindow); } onWindowTitleChanged(metaWindow, refresh) { @@ -1014,7 +1014,7 @@ class AppGroup { const hasFocus = getFocusState(metaWindow); if (hasFocus && this.groupState.hasOwnProperty('lastFocused')) { - this.listState.set({lastFocusedApp: this.groupState.appId}); + this.workspaceState.set({lastFocusedApp: this.groupState.appId}); this.groupState.set({lastFocused: metaWindow}); } this.onFocusChange(hasFocus); @@ -1058,7 +1058,7 @@ class AppGroup { if (this.actor.is_finalized()) return; if (changed) { - setTimeout(() => this.listState.trigger('updateAppGroupIndexes', this.groupState.appId), 0); + setTimeout(() => this.workspaceState.trigger('updateAppGroupIndexes', this.groupState.appId), 0); } if (this.groupState.metaWindows.length === 0 && this.state.appletReady) { @@ -1163,7 +1163,7 @@ class AppGroup { this.hoverMenu.destroy(); } - this.listState.trigger('removeChild', this.actor); + this.workspaceState.trigger('removeChild', this.actor); this.actor.destroy(); if (!skipRefCleanup) { diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js index 1bdead4aa3..c211473466 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js @@ -15,7 +15,7 @@ const {throttle, unref, trySpawnCommandLine} = imports.misc.util; const {createStore} = imports.misc.state; const AppGroup = require('./appGroup'); -const AppList = require('./appList'); +const Workspace = require('./workspace'); const { RESERVE_KEYS, TitleDisplay, @@ -46,22 +46,22 @@ class PinnedFavs { } triggerUpdate(appId, isFavoriteApp) { - const currentAppList = this.params.state.trigger('getCurrentAppList'); - if (!currentAppList) return; + const currentWorkspace = this.params.state.trigger('getCurrentWorkspace'); + if (!currentWorkspace) return; - const refApp = currentAppList.appList.findIndex( appGroup => appGroup.groupState.appId === appId); + const refApp = currentWorkspace.appGroups.findIndex( appGroup => appGroup.groupState.appId === appId); if (refApp === -1) return; // A pinned app with no windows open was unpinned - remove it if (!isFavoriteApp - && currentAppList.appList[refApp] - && currentAppList.appList[refApp].groupState.metaWindows.length === 0) { - currentAppList.appList[refApp].destroy(true); - currentAppList.appList[refApp] = undefined; - currentAppList.appList.splice(refApp, 1); + && currentWorkspace.appGroups[refApp] + && currentWorkspace.appGroups[refApp].groupState.metaWindows.length === 0) { + currentWorkspace.appGroups[refApp].destroy(true); + currentWorkspace.appGroups[refApp] = undefined; + currentWorkspace.appGroups.splice(refApp, 1); } else { // Otherwise, synchronize its pinned state - currentAppList.appList[refApp].groupState.set({isFavoriteApp}); + currentWorkspace.appGroups[refApp].groupState.set({isFavoriteApp}); } } @@ -79,7 +79,7 @@ class PinnedFavs { onFavoritesChange() { this.reload(); - this.params.state.trigger('refreshAllAppLists'); + this.params.state.trigger('refreshAllWorkspaces'); } addFavorite(opts = {appId: null, app: null, pos: -1}) { @@ -105,11 +105,11 @@ class PinnedFavs { // Iterates the app groups in the order they are added as children, this // ensures we always get the correct favorites order regardless of whether // or not pin on drag is enabled. - const currentAppList = this.params.state.trigger('getCurrentAppList'); + const currentWorkspace = this.params.state.trigger('getCurrentWorkspace'); const newFavorites = []; let refActorFound = false; - currentAppList.actor.get_children().forEach( (actor, i) => { - const appGroup = currentAppList.appList.find( appGroup => appGroup.actor === actor ); + currentWorkspace.actor.get_children().forEach( (actor, i) => { + const appGroup = currentWorkspace.appGroups.find( appGroup => appGroup.actor === actor ); if (!appGroup) return; const {app, appId, isFavoriteApp} = appGroup.groupState; let isFavorite = isFavoriteApp; @@ -167,7 +167,7 @@ class GroupedWindowListApplet extends Applet.Applet { this.tracker = Cinnamon.WindowTracker.get_default(); this.recentManager = Gtk.RecentManager.get_default(); - this.appLists = []; + this.workspaces = []; // Initialize the default state. Any values passed through store.set must be declared here // first, or an error will be thrown. this.state = createStore({ @@ -216,29 +216,29 @@ class GroupedWindowListApplet extends Applet.Applet { getAppFromWindow: (metaWindow) => this.getAppFromWindow(metaWindow), getTracker: () => this.tracker, addWindowToAllWorkspaces: (win, app, isFavoriteApp) => { - this.appLists.forEach( appList => { - appList.windowAdded(appList.metaWorkspace, win, app, isFavoriteApp); + this.workspaces.forEach( workspace => { + workspace.windowAdded(workspace.metaWorkspace, win, app, isFavoriteApp); }); this.state.addingWindowToWorkspaces = false; }, removeWindowFromAllWorkspaces: (win) => { - this.appLists.forEach( appList => { - appList.windowRemoved(appList.metaWorkspace, win); + this.workspaces.forEach( workspace => { + workspace.windowRemoved(workspace.metaWorkspace, win); }); this.state.removingWindowFromWorkspaces = false; }, removeWindowFromOtherWorkspaces: (win) => { - this.appLists.forEach( appList => { - if (appList.listState.workspaceIndex === this.state.currentWs) { + this.workspaces.forEach( workspace => { + if (workspace.workspaceState.workspaceIndex === this.state.currentWs) { return; } - appList.windowRemoved(appList.metaWorkspace, win); + workspace.windowRemoved(workspace.metaWorkspace, win); }); this.state.removingWindowFromWorkspaces = false; }, - refreshCurrentAppList: () => this.refreshCurrentAppList(), - refreshAllAppLists: () => this.refreshAllAppLists(), - getCurrentAppList: () => this.getCurrentAppList(), + refreshCurrentWorkspace: () => this.refreshCurrentWorkspace(), + refreshAllWorkspaces: () => this.refreshAllWorkspaces(), + getCurrentWorkspace: () => this.getCurrentWorkspace(), moveLauncher: (source) => this.moveLauncher(source), getAutoStartApps: () => this.getAutoStartApps(), getRecentItems: () => @@ -290,61 +290,61 @@ class GroupedWindowListApplet extends Applet.Applet { this.signals.connect(global.display, 'window-demands-attention', (...args) => this.updateAttentionState(...args)); this.signals.connect(global.display, 'window-created', (...args) => this.onWindowCreated(...args)); this.signals.connect(global.settings, 'changed::panel-edit-mode', (...args) => this.on_panel_edit_mode_changed(...args)); - this.signals.connect(Main.themeManager, 'theme-set', (...args) => this.refreshCurrentAppList(...args)); + this.signals.connect(Main.themeManager, 'theme-set', (...args) => this.refreshCurrentWorkspace(...args)); } bindSettings() { const settingsProps = [ - {key: 'group-apps', value: 'groupApps', cb: this.refreshCurrentAppList}, - {key: 'enable-app-button-dragging', value: 'enableDragging', cb: this.draggableSettingChanged}, - {key: 'launcher-animation-effect', value: 'launcherAnimationEffect', cb: null}, - {key: 'pinned-apps', value: 'pinnedApps', cb: null}, - {key: 'middle-click-action', value: 'middleClickAction', cb: null}, + {key: 'group-apps', value: 'groupApps', cb: this.refreshCurrentWorkspace}, + {key: 'scroll-behavior', value: 'scrollBehavior', cb: null}, {key: 'left-click-action', value: 'leftClickAction', cb: null}, + {key: 'middle-click-action', value: 'middleClickAction', cb: null}, + {key: 'show-all-workspaces', value: 'showAllWorkspaces', cb: this.refreshAllWorkspaces}, + {key: 'cycleMenusHotkey', value: 'cycleMenusHotkey', cb: this.bindAppKeys}, {key: 'show-apps-order-hotkey', value: 'showAppsOrderHotkey', cb: this.bindAppKeys}, {key: 'show-apps-order-timeout', value: 'showAppsOrderTimeout', cb: null}, {key: 'super-num-hotkeys', value: 'SuperNumHotkeys', cb: this.bindAppKeys}, - {key: 'cycleMenusHotkey', value: 'cycleMenusHotkey', cb: this.bindAppKeys}, - {key: 'enable-hover-peek', value: 'enablePeek', cb: null}, - {key: 'onclick-thumbnails', value: 'onClickThumbs', cb: null}, - {key: 'hover-peek-opacity', value: 'peekOpacity', cb: null}, - {key: 'hover-peek-time-in', value: 'peekTimeIn', cb: null}, - {key: 'hover-peek-time-out', value: 'peekTimeOut', cb: null}, - {key: 'thumbnail-timeout', value: 'thumbTimeout', cb: null}, - {key: 'thumbnail-size', value: 'thumbSize', cb: this.updateThumbnailSize}, + {key: 'title-display', value: 'titleDisplay', cb: this.updateTitleDisplay}, + {key: 'launcher-animation-effect', value: 'launcherAnimationEffect', cb: null}, + {key: 'number-display', value: 'numDisplay', cb: this.updateWindowNumberState}, + {key: 'enable-app-button-dragging', value: 'enableDragging', cb: this.draggableSettingChanged}, {key: 'thumbnail-scroll-behavior', value: 'thumbnailScrollBehavior', cb: null}, + {key: 'show-thumbnails', value: 'showThumbs', cb: this.updateVerticalThumbnailState}, + {key: 'animate-thumbnails', value: 'animateThumbs', cb: null}, + {key: 'vertical-thumbnails', value: 'verticalThumbs', cb: this.updateVerticalThumbnailState}, {key: 'sort-thumbnails', value: 'sortThumbs', cb: this.updateVerticalThumbnailState}, { key: 'highlight-last-focused-thumbnail', value: 'highlightLastFocusedThumbnail', cb: this.updateVerticalThumbnailState }, - {key: 'vertical-thumbnails', value: 'verticalThumbs', cb: this.updateVerticalThumbnailState}, - {key: 'show-thumbnails', value: 'showThumbs', cb: this.updateVerticalThumbnailState}, - {key: 'animate-thumbnails', value: 'animateThumbs', cb: null}, - {key: 'number-display', value: 'numDisplay', cb: this.updateWindowNumberState}, - {key: 'title-display', value: 'titleDisplay', cb: this.updateTitleDisplay}, - {key: 'scroll-behavior', value: 'scrollBehavior', cb: null}, + {key: 'onclick-thumbnails', value: 'onClickThumbs', cb: null}, + {key: 'thumbnail-timeout', value: 'thumbTimeout', cb: null}, + {key: 'thumbnail-size', value: 'thumbSize', cb: this.updateThumbnailSize}, + {key: 'enable-hover-peek', value: 'enablePeek', cb: null}, + {key: 'hover-peek-time-in', value: 'peekTimeIn', cb: null}, + {key: 'hover-peek-time-out', value: 'peekTimeOut', cb: null}, + {key: 'hover-peek-opacity', value: 'peekOpacity', cb: null}, {key: 'show-recent', value: 'showRecent', cb: null}, {key: 'autostart-menu-item', value: 'autoStart', cb: null}, {key: 'monitor-move-all-windows', value: 'monitorMoveAllWindows', cb: null}, - {key: 'show-all-workspaces', value: 'showAllWorkspaces', cb: this.refreshAllAppLists} + {key: 'pinned-apps', value: 'pinnedApps', cb: null} ]; - for (let i = 0, len = settingsProps.length; i < len; i++) { + settingsProps.forEach( setting => { this.settings.bind( - settingsProps[i].key, - settingsProps[i].value, - settingsProps[i].cb ? (...args) => settingsProps[i].cb.call(this, ...args) : null + setting.key, + setting.value, + setting.cb ? (...args) => setting.cb.call(this, ...args) : null ); - } + }); this.state.set({lastTitleDisplay: this.state.settings.titleDisplay}); } draggableSettingChanged() { - this.appLists.forEach( workspace => { - workspace.appList.forEach( appGroup => { + this.workspaces.forEach( workspace => { + workspace.appGroups.forEach( appGroup => { appGroup._draggable.inhibit = !this.state.settings.enableDragging; }); }); @@ -369,7 +369,7 @@ class GroupedWindowListApplet extends Applet.Applet { if (initialUpdate) { this.onSwitchWorkspace(); } else { - this.refreshCurrentAppList(); + this.refreshCurrentWorkspace(); } } @@ -383,8 +383,8 @@ class GroupedWindowListApplet extends Applet.Applet { on_panel_edit_mode_changed() { this.state.set({panelEditMode: !this.state.panelEditMode}); - this.appLists.forEach( workspace => { - workspace.appList.forEach( appGroup => { + this.workspaces.forEach( workspace => { + workspace.appGroups.forEach( appGroup => { if (appGroup.hoverMenu) appGroup.hoverMenu.actor.reactive = !this.state.panelEditMode; if (appGroup.rightClickMenu) { appGroup.rightClickMenu.actor.reactive = !this.state.panelEditMode; @@ -416,11 +416,11 @@ class GroupedWindowListApplet extends Applet.Applet { this.state.set({willUnmount: true}); this.unbindAppKeys(); this.signals.disconnectAllSignals(); - for (let i = 0, len = this.appLists.length; i < len; i++) { - if (this.appLists[i]) { - this.appLists[i].destroy(); + this.workspaces.forEach( workspace => { + if (workspace) { + workspace.destroy(); } - } + }); this.settings.finalize(); unref(this, RESERVE_KEYS); } @@ -439,10 +439,10 @@ class GroupedWindowListApplet extends Applet.Applet { onWindowMonitorChanged(display, metaWindow, metaWorkspace) { if (this.state.monitorWatchList.length !== this.numberOfMonitors) { - const appList = this.getCurrentAppList(); - if (appList !== null) { - appList.windowRemoved(metaWorkspace, metaWindow); - appList.windowAdded(metaWorkspace, metaWindow); + const currentWorkspace = this.getCurrentWorkspace(); + if (currentWorkspace !== null) { + currentWorkspace.windowRemoved(metaWorkspace, metaWindow); + currentWorkspace.windowAdded(metaWorkspace, metaWindow); } } } @@ -484,23 +484,19 @@ class GroupedWindowListApplet extends Applet.Applet { } onAppKeyPress(number) { - this.getCurrentAppList().onAppKeyPress(number); + this.getCurrentWorkspace().onAppKeyPress(number); } onNewAppKeyPress(number) { - this.getCurrentAppList().onNewAppKeyPress(number); + this.getCurrentWorkspace().onNewAppKeyPress(number); } showAppsOrder() { - this.getCurrentAppList().showAppsOrder(); + this.getCurrentWorkspace().showAppsOrder(); } cycleMenus() { - this.getCurrentAppList().cycleMenus(); - } - - handleMonitorWindowsPrefsChange(value) { - + this.getCurrentWorkspace().cycleMenus(); } updateMonitorWatchlist() { @@ -538,64 +534,64 @@ class GroupedWindowListApplet extends Applet.Applet { this.state.set({monitorWatchList}); } - refreshCurrentAppList() { - const appList = this.getCurrentAppList(); - if (appList) appList.refreshList(); + refreshCurrentWorkspace() { + const currentWorkspace = this.getCurrentWorkspace(); + if (currentWorkspace) currentWorkspace.refreshList(); } - refreshAllAppLists(options = {exceptCurrentOne: false}) { - const currentAppList = this.getCurrentAppList(); - this.appLists.forEach( appList => { - if (options.exceptCurrentOne && currentAppList === appList) + refreshAllWorkspaces(options = {exceptCurrentOne: false}) { + const currentWorkspace = this.getCurrentWorkspace(); + this.workspaces.forEach( workspace => { + if (options.exceptCurrentOne && currentWorkspace === workspace) return; - setTimeout(() => appList.refreshList(), 0); + setTimeout(() => workspace.refreshList(), 0); }); } updateFavorites() { this.pinnedFavorites.reload(); - this.refreshAllAppLists(); + this.refreshAllWorkspaces(); } updateThumbnailSize() { - this.appLists.forEach( workspace => { - workspace.appList.forEach( appGroup => { + this.workspaces.forEach( workspace => { + workspace.appGroups.forEach( appGroup => { if (appGroup.hoverMenu) appGroup.hoverMenu.updateThumbnailSize(); }); }); } updateActorAttributes(iconSize) { - this.appLists.forEach( workspace => { + this.workspaces.forEach( workspace => { if (!workspace) return; - workspace.appList.forEach( + workspace.appGroups.forEach( appGroup => appGroup.setActorAttributes(iconSize) ); }); } updateWindowNumberState() { - this.appLists.forEach( + this.workspaces.forEach( workspace => workspace.calcAllWindowNumbers() ); } updateAttentionState(display, window) { - this.appLists.forEach( + this.workspaces.forEach( workspace => workspace.updateAttentionState(display, window) ); } onWindowCreated(display, window) { - this.appLists.forEach( + this.workspaces.forEach( workspace => workspace.windowAdded(window.get_workspace(), window) ); } updateVerticalThumbnailState() { - this.appLists.forEach( workspace => { - workspace.appList.forEach( appGroup => { + this.workspaces.forEach( workspace => { + workspace.appGroups.forEach( appGroup => { if (appGroup && appGroup.hoverMenu) { appGroup.hoverMenu.setVerticalSetting(); } @@ -606,11 +602,11 @@ class GroupedWindowListApplet extends Applet.Applet { updateTitleDisplay(titleDisplay) { if (titleDisplay === TitleDisplay.None || this.state.lastTitleDisplay === TitleDisplay.None) { - this.refreshCurrentAppList(); + this.refreshCurrentWorkspace(); } - this.appLists.forEach( workspace => { - workspace.appList.forEach( appGroup => { + this.workspaces.forEach( workspace => { + workspace.appGroups.forEach( appGroup => { if (titleDisplay === TitleDisplay.Focused) { appGroup.hideLabel(); } @@ -636,19 +632,19 @@ class GroupedWindowListApplet extends Applet.Applet { return app; } - getCurrentAppList() { + getCurrentWorkspace() { const metaWorkspace = global.workspace_manager.get_workspace_by_index(this.state.currentWs); - const currentAppList = this.appLists.find( - item => item.metaWorkspace && item.metaWorkspace === metaWorkspace + const currentWorkspace = this.workspaces.find( + workspace => workspace.metaWorkspace && workspace.metaWorkspace === metaWorkspace ); - if (currentAppList) { - return currentAppList; - } else if (typeof this.appLists[this.state.currentWs] !== 'undefined') { - return this.appLists[this.state.currentWs]; - } else if (typeof this.appLists[0] !== 'undefined') { - return this.appLists[0]; + if (currentWorkspace) { + return currentWorkspace; + } else if (typeof this.workspaces[this.state.currentWs] !== 'undefined') { + return this.workspaces[this.state.currentWs]; + } else if (typeof this.workspaces[0] !== 'undefined') { + return this.workspaces[0]; } else { return null; } @@ -696,7 +692,7 @@ class GroupedWindowListApplet extends Applet.Applet { this.state.set({scrollActive: true}); - const appList = this.getCurrentAppList(); + const currentWorkspace = this.getCurrentWorkspace(); let isAppScroll = this.state.settings.scrollBehavior === 2; let direction, source; @@ -712,16 +708,16 @@ class GroupedWindowListApplet extends Applet.Applet { let lastFocusedApp, z, count if (isAppScroll) { - lastFocusedApp = appList.listState.lastFocusedApp; + lastFocusedApp = currentWorkspace.workspaceState.lastFocusedApp; if (!lastFocusedApp) { - lastFocusedApp = appList.appList[0].groupState.appId + lastFocusedApp = currentWorkspace.appGroups[0].groupState.appId } - const focusedIndex = appList.appList.findIndex( + const focusedIndex = currentWorkspace.appGroups.findIndex( appGroup => appGroup.groupState.metaWindows.length > 0 && appGroup.groupState.appId === lastFocusedApp ); z = direction === 0 ? focusedIndex - 1 : focusedIndex + 1; - count = appList.appList.length - 1; + count = currentWorkspace.appGroups.length - 1; } else { if (!source.groupState || source.groupState.metaWindows.length < 1) { return; @@ -736,8 +732,8 @@ class GroupedWindowListApplet extends Applet.Applet { let limit = count * 2; while ((isAppScroll - && (!appList.appList[z] - || !appList.appList[z].groupState.lastFocused)) + && (!currentWorkspace.appGroups[z] + || !currentWorkspace.appGroups[z].groupState.lastFocused)) || (!isAppScroll && (!source.groupState.metaWindows[z] || source.groupState.metaWindows[z] === source.groupState.lastFocused))) { @@ -760,7 +756,7 @@ class GroupedWindowListApplet extends Applet.Applet { } const _window = isAppScroll ? - appList.appList[z].groupState.lastFocused + currentWorkspace.appGroups[z].groupState.lastFocused : source.groupState.metaWindows[z]; Main.activateWindow(_window, global.get_current_time()); setTimeout(() => this.state.set({scrollActive: false}, 4000)); @@ -773,7 +769,7 @@ class GroupedWindowListApplet extends Applet.Applet { if(actor.name === 'xdnd-proxy-actor') return DND.DragMotionResult.CONTINUE; - const appList = this.getCurrentAppList(); + const currentWorkspace = this.getCurrentWorkspace(); const rtl_horizontal = this.state.isHorizontal && St.Widget.get_default_direction () === St.TextDirection.RTL; @@ -784,16 +780,15 @@ class GroupedWindowListApplet extends Applet.Applet { // save data on drag start if(this.state.dragging.posList === null){ this.state.dragging.isForeign = !(source instanceof AppGroup); - const children = appList.actor.get_children(); this.state.dragging.posList = []; - for(let i = 0; i < children.length; i++){ + currentWorkspace.actor.get_children().forEach( child => { let childPos; if(rtl_horizontal) - childPos = this.actor.width - children[i].get_allocation_box()['x1']; + childPos = this.actor.width - child.get_allocation_box()['x1']; else - childPos = children[i].get_allocation_box()[axis[1]]; + childPos = child.get_allocation_box()[axis[1]]; this.state.dragging.posList.push(childPos); - } + }); } // get current position @@ -802,7 +797,7 @@ class GroupedWindowListApplet extends Applet.Applet { pos++; let favLength = 0; - for (const appGroup of appList.appList) { + for (const appGroup of currentWorkspace.appGroups) { if(appGroup.groupState.isFavoriteApp) favLength++; else break; @@ -820,13 +815,13 @@ class GroupedWindowListApplet extends Applet.Applet { if(this.state.dragging.isForeign) { if (this.state.dragging.dragPlaceholder) - appList.actor.set_child_at_index(this.state.dragging.dragPlaceholder.actor, pos); + currentWorkspace.actor.set_child_at_index(this.state.dragging.dragPlaceholder.actor, pos); else { const iconSize = this.getPanelIconSize() * global.ui_scale; this.state.dragging.dragPlaceholder = new DND.GenericDragPlaceholderItem(); this.state.dragging.dragPlaceholder.child.width = iconSize; this.state.dragging.dragPlaceholder.child.height = iconSize; - appList.actor.insert_child_at_index( + currentWorkspace.actor.insert_child_at_index( this.state.dragging.dragPlaceholder.actor, this.state.dragging.pos ); @@ -834,7 +829,7 @@ class GroupedWindowListApplet extends Applet.Applet { } } else - appList.actor.set_child_at_index(source.actor, pos); + currentWorkspace.actor.set_child_at_index(source.actor, pos); } if(this.state.dragging.isForeign) @@ -897,11 +892,11 @@ class GroupedWindowListApplet extends Applet.Applet { } moveLauncher(source) { - let appList = this.getCurrentAppList(); + const currentWorkspace = this.getCurrentWorkspace(); this.clearDragParameters(); Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { - appList.updateAppGroupIndexes(); + currentWorkspace.updateAppGroupIndexes(); // Refresh the group's thumbnails so hoverMenu is aware of the position change // In the case of dragging a group that has a delay before Cinnamon can grab its @@ -919,7 +914,7 @@ class GroupedWindowListApplet extends Applet.Applet { if (refFav > -1) { const pinned = []; //pinned apps found before source - for (const appGroup of appList.appList) { + for (const appGroup of currentWorkspace.appGroups) { if(appGroup.groupState.appId == source.groupState.appId) break; if(!pinned.includes(appGroup.groupState.appId)) @@ -937,7 +932,7 @@ class GroupedWindowListApplet extends Applet.Applet { } } - this.refreshAllAppLists({ exceptCurrentOne: true }); + this.refreshAllWorkspaces({ exceptCurrentOne: true }); return false; }); @@ -946,24 +941,24 @@ class GroupedWindowListApplet extends Applet.Applet { } onWorkspaceRemoved(workspaceManager, index) { - if (this.appLists.length <= index) { + if (this.workspaces.length <= index) { return; } - const removedLists = []; - for (let i = 0; i < this.appLists.length; i++) { - const workspaceIndex = this.appLists[i].metaWorkspace.index(); + const removedWorkspaces = []; + for (let i = 0; i < this.workspaces.length; i++) { + const workspaceIndex = this.workspaces[i].metaWorkspace.index(); if (workspaceIndex === -1) { - if (this.appLists[i] != null) { - this.appLists[i].destroy(); - this.appLists[i] = null; + if (this.workspaces[i] != null) { + this.workspaces[i].destroy(); + this.workspaces[i] = null; } - removedLists.push(i); + removedWorkspaces.push(i); } else { - this.appLists[i].index = workspaceIndex; + this.workspaces[i].index = workspaceIndex; } } - for (let i = removedLists.length - 1; i >= 0; i--) { - this.appLists.splice(removedLists[i], 1); + for (let i = removedWorkspaces.length - 1; i >= 0; i--) { + this.workspaces.splice(removedWorkspaces[i], 1); } this.state.set({currentWs: global.workspace_manager.get_active_workspace_index()}); } @@ -978,41 +973,41 @@ class GroupedWindowListApplet extends Applet.Applet { const metaWorkspace = global.workspace_manager.get_workspace_by_index(this.state.currentWs); // If the workspace we switched to isn't in our list, - // we need to create an AppList for it - let refWorkspace = this.appLists.findIndex( - item => item.metaWorkspace && item.metaWorkspace === metaWorkspace + // we need to create a Workspace for it + let refWorkspace = this.workspaces.findIndex( + workspace => workspace.metaWorkspace && workspace.metaWorkspace === metaWorkspace ); if (refWorkspace === -1) { - this.appLists.push( - new AppList({ + this.workspaces.push( + new Workspace({ metaWorkspace: metaWorkspace, state: this.state, index: this.state.currentWs }) ); - refWorkspace = this.appLists.length - 1; + refWorkspace = this.workspaces.length - 1; } this.actor.remove_all_children(); - this.actor.add_child(this.appLists[refWorkspace].actor); + this.actor.add_child(this.workspaces[refWorkspace].actor); this.actor.queue_relayout(); } onWindowSkipTaskbarChanged(display, metaWindow) { - const appList = this.getCurrentAppList(); + const currentWorkspace = this.getCurrentWorkspace(); if (metaWindow.is_skip_taskbar()) { - appList.windowRemoved(appList.metaWorkspace, metaWindow); + currentWorkspace.windowRemoved(currentWorkspace.metaWorkspace, metaWindow); return; } - - appList.windowAdded(appList.metaWorkspace, metaWindow); + + currentWorkspace.windowAdded(currentWorkspace.metaWorkspace, metaWindow); } onUIScaleChange() { this.state.set({thumbnailCloseButtonOffset: global.ui_scale > 1 ? -10 : 0}); - this.refreshAllAppLists(); + this.refreshAllWorkspaces(); } } diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/menus.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/menus.js index f1774fedbe..0c0f40dff9 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/menus.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/menus.js @@ -420,7 +420,7 @@ class AppMenuButtonRightClickMenu extends Applet.AppletPopupMenu { if (stdout) { setTimeout(() => { this.state.trigger('addFavorite', {appId: stdout.trim(), app: null, pos: -1}); - this.state.trigger('refreshCurrentAppList'); + this.state.trigger('refreshCurrentWorkspace'); }, 2000); } }); @@ -1285,4 +1285,4 @@ module.exports = { AppMenuButtonRightClickMenu, HoverMenuController, AppThumbnailHoverMenu -}; \ No newline at end of file +}; diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json index d0e63eff20..fd951cedb7 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json @@ -33,17 +33,6 @@ "show-all-workspaces" ] }, - "appButtonsSection": { - "type" : "section", - "title" : "Application Buttons", - "keys": [ - "title-display", - "launcher-animation-effect", - "number-display", - "pinned-apps", - "enable-app-button-dragging" - ] - }, "hotKeysSection": { "type" : "section", "title" : "Hot Keys", @@ -54,6 +43,16 @@ "super-num-hotkeys" ] }, + "appButtonsSection": { + "type" : "section", + "title" : "Application Buttons", + "keys": [ + "title-display", + "launcher-animation-effect", + "number-display", + "enable-app-button-dragging" + ] + }, "thumbnailsSection": { "type" : "section", "title" : "Thumbnails", @@ -89,21 +88,11 @@ ] } }, - "number-display": { + + "group-apps": { "type": "checkbox", "default": true, - "description": "Show window count numbers" - }, - "title-display": { - "type": "combobox", - "default": 1, - "description": "Button label", - "options": { - "None": 1, - "Application name": 2, - "Window title": 3, - "Window title (only for the focused window)": 4 - } + "description": "Group windows by application" }, "scroll-behavior": { "type": "combobox", @@ -135,35 +124,11 @@ "Close last focused window in group": 3 } }, - "pinned-apps": { - "type": "generic", - "default": ["nemo.desktop", "firefox.desktop", "org.gnome.Terminal.desktop"] - }, - "group-apps": { - "type": "checkbox", - "default": true, - "description": "Group windows by application" - }, "show-all-workspaces": { "type": "checkbox", "default": false, "description": "Show windows from all workspaces" }, - "enable-app-button-dragging": { - "type": "checkbox", - "default": true, - "description": "Enable app button dragging" - }, - "launcher-animation-effect": { - "type": "combobox", - "default": 3, - "description": "Launcher animation", - "options": { - "None": 1, - "Fade": 2, - "Scale": 3 - } - }, "cycleMenusHotkey": { "type": "keybinding", "default": "", @@ -188,28 +153,37 @@ "default": true, "description": "Enable Super+ shortcut to switch/open apps" }, - "thumbnail-timeout": { - "dependency": "!onclick-thumbnails", + "title-display": { "type": "combobox", - "default": 250, - "description": "Delay before showing thumbnails", + "default": 1, + "description": "Button label", "options": { - "50 ms": 50, - "250 ms": 250, - "500 ms": 500 + "None": 1, + "Application name": 2, + "Window title": 3, + "Window title (only for the focused window)": 4 } }, - "thumbnail-size": { + "launcher-animation-effect": { "type": "combobox", - "default": 6, - "description": "Thumbnail size", + "default": 3, + "description": "Launcher animation", "options": { - "Small": 3, - "Medium": 6, - "Large": 9, - "Largest": 12 + "None": 1, + "Fade": 2, + "Scale": 3 } }, + "number-display": { + "type": "checkbox", + "default": true, + "description": "Show window count numbers" + }, + "enable-app-button-dragging": { + "type": "checkbox", + "default": true, + "description": "Enable app button dragging" + }, "thumbnail-scroll-behavior": { "type": "checkbox", "default": false, @@ -245,21 +219,27 @@ "default": false, "description": "Click to show thumbnails" }, - "show-recent": { - "type": "checkbox", - "default": true, - "description": "Show recent items" - }, - "autostart-menu-item": { - "type": "checkbox", - "default": false, - "description": "Show autostart option" + "thumbnail-timeout": { + "dependency": "!onclick-thumbnails", + "type": "combobox", + "default": 250, + "description": "Delay before showing thumbnails", + "options": { + "50 ms": 50, + "250 ms": 250, + "500 ms": 500 + } }, - "monitor-move-all-windows": { - "type": "checkbox", - "default": true, - "description": "Apply the monitor move option to all windows", - "tooltip": "When clicking \"Move to monitor\" in the context menu, this option will move all of an app's windows instead of just the last focused window from the app." + "thumbnail-size": { + "type": "combobox", + "default": 6, + "description": "Thumbnail size", + "options": { + "Small": 3, + "Medium": 6, + "Large": 9, + "Largest": 12 + } }, "enable-hover-peek": { "type": "checkbox", @@ -298,5 +278,26 @@ "step": 1, "units": "percent", "description": "Window opacity" + }, + "show-recent": { + "type": "checkbox", + "default": true, + "description": "Show recent items" + }, + "autostart-menu-item": { + "type": "checkbox", + "default": false, + "description": "Show autostart option" + }, + "monitor-move-all-windows": { + "type": "checkbox", + "default": true, + "description": "Apply the monitor move option to all windows", + "tooltip": "When clicking \"Move to monitor\" in the context menu, this option will move all of an app's windows instead of just the last focused window from the app." + }, + + "pinned-apps": { + "type": "generic", + "default": ["nemo.desktop", "firefox.desktop", "org.gnome.Terminal.desktop"] } -} \ No newline at end of file +} diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appList.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js similarity index 75% rename from files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appList.js rename to files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js index 3f1d389123..51de280dae 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appList.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js @@ -7,17 +7,17 @@ const {createStore} = imports.misc.state; const AppGroup = require('./appGroup'); const {RESERVE_KEYS} = require('./constants'); -class AppList { +class Workspace { constructor(params) { this.state = params.state; this.state.connect({ orientation: () => this.on_orientation_changed(false) }); - this.listState = createStore({ + this.workspaceState = createStore({ workspaceIndex: params.index, lastFocusedApp: null }); - this.listState.connect({ + this.workspaceState.connect({ getWorkspace: () => this.metaWorkspace, updateAppGroupIndexes: () => this.updateAppGroupIndexes(), closeAllRightClickMenus: (cb) => this.closeAllRightClickMenus(cb), @@ -31,7 +31,7 @@ class AppList { this.actor.remove_child(actor); }, updateFocusState: (focusedAppId) => { - this.appList.forEach( appGroup => { + this.appGroups.forEach( appGroup => { if (focusedAppId === appGroup.groupState.appId) return; appGroup.onFocusChange(false); }); @@ -45,7 +45,7 @@ class AppList { this.manager = new Clutter.BoxLayout({orientation: Clutter.Orientation[managerOrientation]}); this.actor = new Clutter.Actor({layout_manager: this.manager}); - this.appList = []; + this.appGroups = []; this.lastFocusedApp = null; // Connect all the signals @@ -70,7 +70,7 @@ class AppList { getWindowCount(appId) { let windowCount = 0; - this.appList.forEach( appGroup => { + this.appGroups.forEach( appGroup => { if (appGroup.groupState.appId !== appId) return; windowCount += appGroup.groupState.metaWindows.length; }); @@ -78,44 +78,44 @@ class AppList { } closeAllHoverMenus(cb) { - for (let i = 0, len = this.appList.length; i < len; i++) { - const {hoverMenu, groupState} = this.appList[i]; + this.appGroups.forEach( appGroup => { + const {hoverMenu, groupState} = appGroup; if (hoverMenu && hoverMenu.isOpen) { groupState.set({thumbnailMenuEntered: false}); hoverMenu.close(true); } - } + }); if (typeof cb === 'function') cb(); } closeAllRightClickMenus(cb) { - for (let i = 0, len = this.appList.length; i < len; i++) { - if (typeof this.appList[i].rightClickMenu !== 'undefined' && this.appList[i].rightClickMenu.isOpen) { - this.appList[i].rightClickMenu.close(); + this.appGroups.forEach( appGroup => { + if (typeof appGroup.rightClickMenu !== 'undefined' && appGroup.rightClickMenu.isOpen) { + appGroup.rightClickMenu.close(); } - } + }); if (typeof cb === 'function') cb(); } onAppKeyPress(number) { - if (!this.appList[number - 1]) return; - this.appList[number - 1].onAppKeyPress(number); + if (!this.appGroups[number - 1]) return; + this.appGroups[number - 1].onAppKeyPress(number); } onNewAppKeyPress(number) { - if (number > this.appList.length) return; - this.appList[number - 1].launchNewInstance(); + if (number > this.appGroups.length) return; + this.appGroups[number - 1].launchNewInstance(); } showAppsOrder() { - for (let i = 0, len = this.appList.length; i < len; i++) { - this.appList[i].showOrderLabel(i); + for (let i = 0, len = this.appGroups.length; i < len; i++) { + this.appGroups[i].showOrderLabel(i); } setTimeout(() => this.calcAllWindowNumbers(), this.state.settings.showAppsOrderTimeout); } cycleMenus(r = 0) { - if (r > this.appList.length) { + if (r > this.appGroups.length) { this.state.set({lastCycled: -1}); return; } @@ -124,16 +124,16 @@ class AppList { this.lastCycledTime = Date.now(); if (lastCycled < 0) { - lastCycled = this.appList.findIndex( - app => app.groupState.appId === this.listState.lastFocusedApp + lastCycled = this.appGroups.findIndex( + appGroup => appGroup.groupState.appId === this.workspaceState.lastFocusedApp ); } - if (lastCycled < 0 || lastCycled > this.appList.length - 1) { + if (lastCycled < 0 || lastCycled > this.appGroups.length - 1) { lastCycled = 0; } - const refApp = this.appList[lastCycled]; + const refApp = this.appGroups[lastCycled]; lastCycled++; this.state.set({lastCycled}); @@ -170,11 +170,11 @@ class AppList { } refreshList() { - for (let i = 0, len = this.appList.length; i < len; i++) { - this.appList[i].destroy(); - this.appList[i] = null; - } - this.appList = []; + this.appGroups.forEach( appGroup => { + appGroup.destroy(); + appGroup = null; + }); + this.appGroups = []; this.loadFavorites(); this.refreshApps(); } @@ -215,7 +215,7 @@ class AppList { } updateAttentionState(display, window) { - this.appList.forEach( appGroup => { + this.appGroups.forEach( appGroup => { if (appGroup.groupState.metaWindows) { appGroup.onWindowDemandsAttention(window); } @@ -272,11 +272,11 @@ class AppList { refWindow = -1, transientFavorite = false; - for (let i = 0; i < this.appList.length; i++) { - if (app === this.appList[i].groupState.app) { + for (let i = 0; i < this.appGroups.length; i++) { + if (app === this.appGroups[i].groupState.app) { refApp = i; } - const ref = this.appList[i].groupState.metaWindows.indexOf(metaWindow); + const ref = this.appGroups[i].groupState.metaWindows.indexOf(metaWindow); if (ref > -1) { if (refApp === -1 || !this.state.settings.groupApps) { refApp = i; @@ -299,7 +299,7 @@ class AppList { const initApp = (idx) => { const appGroup = new AppGroup({ state: this.state, - listState: this.listState, + workspaceState: this.workspaceState, app, isFavoriteApp, metaWorkspace, @@ -309,11 +309,11 @@ class AppList { if(idx > -1) { this.actor.insert_child_at_index(appGroup.actor, idx); - this.appList.splice(idx, 0, appGroup); + this.appGroups.splice(idx, 0, appGroup); } else { this.actor.add_child(appGroup.actor); - this.appList.push(appGroup); + this.appGroups.push(appGroup); } appGroup.windowAdded(metaWindow); }; @@ -322,9 +322,9 @@ class AppList { initApp(-1); } else if (metaWindow) { if (this.state.settings.groupApps) { - this.appList[refApp].windowAdded(metaWindow); - } else if (transientFavorite && this.appList[refApp].groupState.metaWindows.length === 0) { - this.appList[refApp].windowAdded(metaWindow); + this.appGroups[refApp].windowAdded(metaWindow); + } else if (transientFavorite && this.appGroups[refApp].groupState.metaWindows.length === 0) { + this.appGroups[refApp].windowAdded(metaWindow); } else if (refWindow === -1) { initApp(refApp+1); } @@ -332,20 +332,20 @@ class AppList { } calcAllWindowNumbers() { - for (let i = 0, len = this.appList.length; i < len; i++) { - this.appList[i].calcWindowNumber(this.appList[i].groupState.metaWindows); - } + this.appGroups.forEach( appGroup => { + appGroup.calcWindowNumber(appGroup.groupState.metaWindows); + }); } updateAppGroupIndexes() { - const newAppList = []; + const newAppGroups = []; this.actor.get_children().forEach( child => { - const appGroup = this.appList.find( appGroup => appGroup.actor === child); + const appGroup = this.appGroups.find( appGroup => appGroup.actor === child); if (appGroup) { - newAppList.push(appGroup); + newAppGroups.push(appGroup); } }); - this.appList = newAppList; + this.appGroups = newAppGroups; } windowRemoved(metaWorkspace, metaWindow) { @@ -366,7 +366,7 @@ class AppList { } let refWindow = -1; - const refApp = this.appList.findIndex( appGroup => { + const refApp = this.appGroups.findIndex( appGroup => { const window = appGroup.groupState.metaWindows.findIndex( win => win === metaWindow); if (window > -1) { refWindow = window; @@ -375,45 +375,45 @@ class AppList { }); if (refApp > -1) { - this.appList[refApp].windowRemoved(metaWorkspace, metaWindow, refWindow, (appId, isFavoriteApp) => { + this.appGroups[refApp].windowRemoved(metaWorkspace, metaWindow, refWindow, (appId, isFavoriteApp) => { if (isFavoriteApp) { if (this.state.settings.groupApps || this.getWindowCount(appId) === 0) { - this.appList[refApp].groupState.set({groupReady: false, lastFocused: null}); - this.appList[refApp].actor.set_style_pseudo_class('closed'); - this.appList[refApp].actor.remove_style_class_name('grouped-window-list-item-demands-attention'); - this.appList[refApp].setActiveStatus(false); + this.appGroups[refApp].groupState.set({groupReady: false, lastFocused: null}); + this.appGroups[refApp].actor.set_style_pseudo_class('closed'); + this.appGroups[refApp].actor.remove_style_class_name('grouped-window-list-item-demands-attention'); + this.appGroups[refApp].setActiveStatus(false); if (this.state.settings.titleDisplay > 1) { - this.appList[refApp].hideLabel(); + this.appGroups[refApp].hideLabel(); } } else { - // pinned app closed in ungrouped-windows mode and another instance of app already exists in appList + // pinned app closed in ungrouped-windows mode and another instance of app already exists in appGroups // move other instance to original apps' position - const refAppId = this.appList[refApp].groupState.appId; + const refAppId = this.appGroups[refApp].groupState.appId; - this.appList[refApp].destroy(true); - this.appList[refApp] = undefined; - this.appList.splice(refApp, 1); + this.appGroups[refApp].destroy(true); + this.appGroups[refApp] = undefined; + this.appGroups.splice(refApp, 1); - const otherApp = this.appList.findIndex( + const otherApp = this.appGroups.findIndex( appGroup => appGroup.groupState.appId === refAppId ); - const otherAppObject = this.appList[otherApp] + const otherAppObject = this.appGroups[otherApp] // in edge case when multiple apps of the same program are favorited, do not move other app if(!otherAppObject.groupState.isFavoriteApp) { - this.appList.splice(otherApp, 1); + this.appGroups.splice(otherApp, 1); this.actor.set_child_at_index(otherAppObject.actor, refApp); - this.appList.splice(refApp, 0, otherAppObject); + this.appGroups.splice(refApp, 0, otherAppObject); // change previously unpinned app status to pinned otherAppObject.groupState.isFavoriteApp = true; } } } else { - this.appList[refApp].destroy(true); - this.appList[refApp] = undefined; - this.appList.splice(refApp, 1); + this.appGroups[refApp].destroy(true); + this.appGroups[refApp] = undefined; + this.appGroups.splice(refApp, 1); } }); } @@ -421,14 +421,12 @@ class AppList { destroy() { this.signals.disconnectAllSignals(); - for (let i = 0, len = this.appList.length; i < len; i++) { - this.appList[i].destroy(); - } - this.listState.destroy(); + this.appGroups.forEach( appGroup => appGroup.destroy() ); + this.workspaceState.destroy(); this.manager = null; this.actor.destroy(); unref(this, RESERVE_KEYS); } } -module.exports = AppList; +module.exports = Workspace; From ab53b04fbe2fbb4085d70cc68786b48af98b94d7 Mon Sep 17 00:00:00 2001 From: fredcw Date: Wed, 7 Aug 2024 06:36:45 +0100 Subject: [PATCH 2/2] Move unneeded misc/state.js move js/misc/state.js to grouped-window-list@cinnamon.org folder as it not used (and unlikely to be used) anywhere else. --- .../applets/grouped-window-list@cinnamon.org/appGroup.js | 2 +- .../cinnamon/applets/grouped-window-list@cinnamon.org/applet.js | 2 +- .../cinnamon/applets/grouped-window-list@cinnamon.org}/state.js | 2 ++ .../applets/grouped-window-list@cinnamon.org/workspace.js | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) rename {js/misc => files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org}/state.js (99%) diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js index 3e78967bf5..6a0f0990c5 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js @@ -10,8 +10,8 @@ const PopupMenu = imports.ui.popupMenu; const Mainloop = imports.mainloop; const {SignalManager} = imports.misc.signalManager; const {unref} = imports.misc.util; -const {createStore} = imports.misc.state; +const createStore = require('./state'); const {AppMenuButtonRightClickMenu, HoverMenuController, AppThumbnailHoverMenu} = require('./menus'); const { FLASH_INTERVAL, diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js index c211473466..edbaf73a93 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js @@ -12,8 +12,8 @@ const DND = imports.ui.dnd; const {AppletSettings} = imports.ui.settings; const {SignalManager} = imports.misc.signalManager; const {throttle, unref, trySpawnCommandLine} = imports.misc.util; -const {createStore} = imports.misc.state; +const createStore = require('./state'); const AppGroup = require('./appGroup'); const Workspace = require('./workspace'); const { diff --git a/js/misc/state.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/state.js similarity index 99% rename from js/misc/state.js rename to files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/state.js index 3c50a57faa..714422334f 100644 --- a/js/misc/state.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/state.js @@ -317,3 +317,5 @@ function createStore(state = {}, listeners = [], connections = 0) { return getAPIWithObject(state); } + +module.exports = createStore; \ No newline at end of file diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js index 51de280dae..4329489297 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js @@ -2,8 +2,8 @@ const Clutter = imports.gi.Clutter; const Main = imports.ui.main; const {SignalManager} = imports.misc.signalManager; const {unref} = imports.misc.util; -const {createStore} = imports.misc.state; +const createStore = require('./state'); const AppGroup = require('./appGroup'); const {RESERVE_KEYS} = require('./constants');