summaryrefslogtreecommitdiffstats
path: root/extensions/44/vertical-workspaces/lib/panel.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/44/vertical-workspaces/lib/panel.js')
-rw-r--r--extensions/44/vertical-workspaces/lib/panel.js375
1 files changed, 217 insertions, 158 deletions
diff --git a/extensions/44/vertical-workspaces/lib/panel.js b/extensions/44/vertical-workspaces/lib/panel.js
index 3f44ae7..898407a 100644
--- a/extensions/44/vertical-workspaces/lib/panel.js
+++ b/extensions/44/vertical-workspaces/lib/panel.js
@@ -10,188 +10,247 @@
'use strict';
-const { GLib } = imports.gi;
-const Main = imports.ui.main;
-const Me = imports.misc.extensionUtils.getCurrentExtension();
-const _Util = Me.imports.lib.util;
+const Clutter = imports.gi.Clutter;
-const ANIMATION_TIME = imports.ui.overview.ANIMATION_TIME;
+const Main = imports.ui.main;
+const Overview = imports.ui.overview;
+const Panel = imports.ui.panel;
+let Me;
let opt;
-let _firstRun = true;
-let _showingOverviewConId;
-let _hidingOverviewConId;
-let _styleChangedConId;
+const ANIMATION_TIME = Overview.ANIMATION_TIME;
-function update(reset = false) {
- opt = Me.imports.lib.settings.opt;
- const moduleEnabled = opt.get('panelModule', true);
- // Avoid conflict with other extensions
- const conflict = _Util.getEnabledExtensions('dash-to-panel').length ||
- _Util.getEnabledExtensions('hidetopbar').length;
- reset = reset || (!_firstRun && !moduleEnabled);
+var PanelModule = class {
+ constructor(me) {
+ Me = me;
+ opt = Me.opt;
- // don't even touch this module if disabled or in potential conflict
- if (_firstRun && (reset || conflict))
- return;
+ this._firstActivation = true;
+ this.moduleEnabled = false;
+ this._overrides = null;
- _firstRun = false;
+ this._showingOverviewConId = 0;
+ this._hidingOverviewConId = 0;
+ this._styleChangedConId = 0;
+ }
- const panelBox = Main.layoutManager.panelBox;
- if (reset || !moduleEnabled) {
- // _disconnectPanel();
- reset = true;
- _setPanelPosition(reset);
- _updateOverviewConnection(reset);
- _reparentPanel(false);
+ cleanGlobals() {
+ Me = null;
+ opt = null;
+ }
- _updateStyleChangedConnection(reset);
+ update(reset) {
+ this.moduleEnabled = opt.get('panelModule');
+ const conflict = Me.Util.getEnabledExtensions('dash-to-panel').length ||
+ Me.Util.getEnabledExtensions('hidetopbar').length;
- panelBox.translation_y = 0;
- Main.panel.opacity = 255;
- _setPanelStructs(true);
- return;
+ if (conflict && !reset)
+ console.warn(`[${Me.metadata.name}] Warning: "Panel" module disabled due to potential conflict with another extension`);
+
+ reset = reset || !this.moduleEnabled || conflict || Main.sessionMode.isLocked;
+
+ // don't touch original code if module disabled
+ if (reset && !this._firstActivation) {
+ this._disableModule();
+ } else if (!reset) {
+ this._firstActivation = false;
+ this._activateModule();
+ }
+ if (reset && this._firstActivation)
+ console.debug(' PanelModule - Keeping untouched');
+ }
+
+ _activateModule() {
+ if (!this._overrides)
+ this._overrides = new Me.Util.Overrides();
+
+ const panelBox = Main.layoutManager.panelBox;
+
+ this._setPanelPosition();
+ this._updateStyleChangedConnection();
+
+ if (opt.PANEL_MODE === 0) {
+ this._updateOverviewConnection(true);
+ this._reparentPanel(false);
+ panelBox.translation_y = 0;
+ Main.panel.opacity = 255;
+ this._setPanelStructs(true);
+ } else if (opt.PANEL_MODE === 1) {
+ if (opt.SHOW_WS_PREVIEW_BG) {
+ this._reparentPanel(true);
+ if (opt.OVERVIEW_MODE2) {
+ // in OM2 if the panel has been moved to the overviewGroup move panel above all
+ Main.layoutManager.overviewGroup.set_child_above_sibling(panelBox, null);
+ this._updateOverviewConnection();
+ } else {
+ // otherwise move the panel below overviewGroup so it can get below workspacesDisplay
+ Main.layoutManager.overviewGroup.set_child_below_sibling(panelBox, Main.overview._overview);
+ this._updateOverviewConnection(true);
+ }
+ this._showPanel(true);
+ } else {
+ // if ws preview bg is disabled, panel can stay in uiGroup
+ this._reparentPanel(false);
+ this._showPanel(false);
+ this._updateOverviewConnection();
+ }
+ // _connectPanel();
+ } else if (opt.PANEL_MODE === 2) {
+ this._updateOverviewConnection(true);
+ this._reparentPanel(false);
+ this._showPanel(false);
+ // _connectPanel();
+ }
+ this._setPanelStructs(opt.PANEL_MODE === 0);
+ Main.layoutManager._updateHotCorners();
+
+ this._overrides.addOverride('ActivitiesButton', Panel.ActivitiesButton.prototype, ActivitiesButton);
+
+ console.debug(' PanelModule - Activated');
}
- _setPanelPosition();
- _updateStyleChangedConnection();
+ _disableModule() {
+ const reset = true;
+ this._setPanelPosition(reset);
+ this._updateOverviewConnection(reset);
+ this._reparentPanel(false);
+
+ this._updateStyleChangedConnection(reset);
- if (opt.PANEL_MODE === 0) {
- _updateOverviewConnection(true);
- _reparentPanel(false);
+ const panelBox = Main.layoutManager.panelBox;
panelBox.translation_y = 0;
Main.panel.opacity = 255;
- _setPanelStructs(true);
- } else if (opt.PANEL_MODE === 1) {
- if (opt.SHOW_WS_PREVIEW_BG) {
- _reparentPanel(true);
- if (opt.OVERVIEW_MODE2) {
- // in OM2 if the panel has been moved to the overviewGroup move panel above all
- Main.layoutManager.overviewGroup.set_child_above_sibling(panelBox, null);
- _updateOverviewConnection();
- } else {
- // otherwise move the panel below overviewGroup so it can get below workspacesDisplay
- Main.layoutManager.overviewGroup.set_child_below_sibling(panelBox, Main.overview._overview);
- _updateOverviewConnection(true);
+ this._setPanelStructs(true);
+ if (this._overrides)
+ this._overrides.removeAll();
+ this._overrides = null;
+
+ console.debug(' PanelModule - Disabled');
+ }
+
+ _setPanelPosition(reset = false) {
+ const geometry = global.display.get_monitor_geometry(global.display.get_primary_monitor());
+ const panelBox = Main.layoutManager.panelBox;
+ const panelHeight = Main.panel.height; // panelBox height can be 0 after shell start
+
+ if (opt.PANEL_POSITION_TOP || reset)
+ panelBox.set_position(geometry.x, geometry.y);
+ else
+ panelBox.set_position(geometry.x, geometry.y + geometry.height - panelHeight);
+ }
+
+ _updateStyleChangedConnection(reset = false) {
+ if (reset) {
+ if (this._styleChangedConId) {
+ Main.panel.disconnect(this._styleChangedConId);
+ this._styleChangedConId = 0;
+ }
+ } else if (!this._styleChangedConId) {
+ this._styleChangedConId = Main.panel.connect('style-changed', () => {
+ if (opt.PANEL_MODE === 1 && !opt.OVERVIEW_MODE2)
+ Main.panel.add_style_pseudo_class('overview');
+ else if (opt.OVERVIEW_MODE2)
+ Main.panel.remove_style_pseudo_class('overview');
+ });
+ }
+ }
+
+ _updateOverviewConnection(reset = false) {
+ if (reset) {
+ if (this._hidingOverviewConId) {
+ Main.overview.disconnect(this._hidingOverviewConId);
+ this._hidingOverviewConId = 0;
+ }
+ if (this._showingOverviewConId) {
+ Main.overview.disconnect(this._showingOverviewConId);
+ this._showingOverviewConId = 0;
}
- _showPanel(true);
} else {
- // if ws preview bg is disabled, panel can stay in uiGroup
- _reparentPanel(false);
- _showPanel(false);
- _updateOverviewConnection();
+ if (!this._hidingOverviewConId) {
+ this._hidingOverviewConId = Main.overview.connect('hiding', () => {
+ if (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2)
+ this._showPanel(false);
+ });
+ }
+ if (!this._showingOverviewConId) {
+ this._showingOverviewConId = Main.overview.connect('showing', () => {
+ if (Main.layoutManager._startingUp)
+ return;
+ if (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2 || Main.layoutManager.panelBox.translation_y)
+ this._showPanel(true);
+ });
+ }
}
- // _connectPanel();
- } else if (opt.PANEL_MODE === 2) {
- _updateOverviewConnection(true);
- _reparentPanel(false);
- _showPanel(false);
- // _connectPanel();
}
- _setPanelStructs(opt.PANEL_MODE === 0);
- Main.layoutManager._updateHotCorners();
-}
-
-function _setPanelPosition(reset = false) {
- const geometry = global.display.get_monitor_geometry(global.display.get_primary_monitor());
- const panelBox = Main.layoutManager.panelBox;
- const panelHeight = Main.panel.height; // panelBox height can be 0 after shell start
-
- if (opt.PANEL_POSITION_TOP || reset)
- panelBox.set_position(geometry.x, geometry.y);
- else
- panelBox.set_position(geometry.x, geometry.y + geometry.height - panelHeight);
-}
-
-function _updateStyleChangedConnection(reset = false) {
- if (reset) {
- if (_styleChangedConId) {
- Main.panel.disconnect(_styleChangedConId);
- _styleChangedConId = 0;
+
+ _reparentPanel(reparent = false) {
+ const panel = Main.layoutManager.panelBox;
+ if (reparent && panel.get_parent() === Main.layoutManager.uiGroup) {
+ Main.layoutManager.uiGroup.remove_child(panel);
+ Main.layoutManager.overviewGroup.add_child(panel);
+ } else if (!reparent && panel.get_parent() === Main.layoutManager.overviewGroup) {
+ Main.layoutManager.overviewGroup.remove_child(panel);
+ // return the panel at default position, panel shouldn't cover objects that should be above
+ Main.layoutManager.uiGroup.insert_child_at_index(panel, 4);
}
- } else if (!_styleChangedConId) {
- Main.panel.connect('style-changed', () => {
- if (opt.PANEL_MODE === 1)
- Main.panel.add_style_pseudo_class('overview');
- else if (opt.OVERVIEW_MODE2)
- Main.panel.remove_style_pseudo_class('overview');
+ }
+
+ _setPanelStructs(state) {
+ Main.layoutManager._trackedActors.forEach(a => {
+ if (a.actor === Main.layoutManager.panelBox)
+ a.affectsStruts = state;
});
+
+ // workaround to force maximized windows to resize after removing affectsStruts
+ // simulation of minimal swipe gesture to the opposite direction
+ // todo - needs better solution!!!!!!!!!!!
+ // const direction = _getAppGridAnimationDirection() === 2 ? 1 : -1;
+ // Main.overview._swipeTracker._beginTouchSwipe(null, global.get_current_time(), 1, 1);
+ // Main.overview._swipeTracker._updateGesture(null, global.get_current_time(), direction, 1);
+ // GLib.timeout_add(0, 50, () => Main.overview._swipeTracker._endGesture(global.get_current_time(), 1, true));*/
}
-}
-function _updateOverviewConnection(reset = false) {
- if (reset) {
- if (_hidingOverviewConId) {
- Main.overview.disconnect(_hidingOverviewConId);
- _hidingOverviewConId = 0;
- }
- if (_showingOverviewConId) {
- Main.overview.disconnect(_showingOverviewConId);
- _showingOverviewConId = 0;
- }
- } else {
- if (!_hidingOverviewConId) {
- _hidingOverviewConId = Main.overview.connect('hiding', () => {
- if (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2)
- _showPanel(false);
+ _showPanel(show = true) {
+ if (show) {
+ Main.panel.opacity = 255;
+ Main.layoutManager.panelBox.ease({
+ duration: ANIMATION_TIME,
+ translation_y: 0,
+ onComplete: () => {
+ this._setPanelStructs(opt.PANEL_MODE === 0);
+ },
});
- }
- if (!_showingOverviewConId) {
- _showingOverviewConId = Main.overview.connect('showing', () => {
- if (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2 || Main.layoutManager.panelBox.translation_y)
- _showPanel(true);
+ } else {
+ const panelHeight = Main.panel.height;
+ Main.layoutManager.panelBox.ease({
+ duration: ANIMATION_TIME,
+ translation_y: opt.PANEL_POSITION_TOP ? -panelHeight + 1 : panelHeight - 1,
+ onComplete: () => {
+ Main.panel.opacity = 0;
+ this._setPanelStructs(opt.PANEL_MODE === 0);
+ },
});
}
}
-}
-
-function _reparentPanel(reparent = false) {
- const panel = Main.layoutManager.panelBox;
- if (reparent && panel.get_parent() === Main.layoutManager.uiGroup) {
- Main.layoutManager.uiGroup.remove_child(panel);
- Main.layoutManager.overviewGroup.add_child(panel);
- } else if (!reparent && panel.get_parent() === Main.layoutManager.overviewGroup) {
- Main.layoutManager.overviewGroup.remove_child(panel);
- // return the panel at default position, panel shouldn't cover objects that should be above
- Main.layoutManager.uiGroup.insert_child_at_index(panel, 4);
- }
-}
-
-function _setPanelStructs(state) {
- Main.layoutManager._trackedActors.forEach(a => {
- if (a.actor === Main.layoutManager.panelBox)
- a.affectsStruts = state;
- });
-
- // workaround to force maximized windows to resize after removing affectsStruts
- // simulation of minimal swipe gesture to the opposite direction
- // todo - needs better solution!!!!!!!!!!!
- // const direction = _getAppGridAnimationDirection() === 2 ? 1 : -1;
- // Main.overview._swipeTracker._beginTouchSwipe(null, global.get_current_time(), 1, 1);
- // Main.overview._swipeTracker._updateGesture(null, global.get_current_time(), direction, 1);
- // GLib.timeout_add(0, 50, () => Main.overview._swipeTracker._endGesture(global.get_current_time(), 1, true));*/
-}
-
-function _showPanel(show = true) {
- if (show) {
- Main.panel.opacity = 255;
- Main.layoutManager.panelBox.ease({
- duration: ANIMATION_TIME,
- translation_y: 0,
- onComplete: () => {
- _setPanelStructs(opt.PANEL_MODE === 0);
- },
- });
- } else {
- const panelHeight = Main.panel.height;
- Main.layoutManager.panelBox.ease({
- duration: ANIMATION_TIME,
- translation_y: opt.PANEL_POSITION_TOP ? -panelHeight + 1 : panelHeight - 1,
- onComplete: () => {
- Main.panel.opacity = 0;
- _setPanelStructs(opt.PANEL_MODE === 0);
- },
- });
- }
-}
+};
+
+const ActivitiesButton = {
+ vfunc_event(event) {
+ if (event.type() === Clutter.EventType.TOUCH_END ||
+ event.type() === Clutter.EventType.BUTTON_RELEASE) {
+ if (Main.overview.shouldToggleByCornerOrButton()) {
+ if (event.get_button() === Clutter.BUTTON_SECONDARY && !Main.overview.dash.showAppsButton.checked) {
+ Main.overview.show(2);
+ Main.overview.dash.showAppsButton.checked = true;
+ } else {
+ Main.overview.toggle();
+ }
+ }
+ } else if (event.type() === Clutter.EventType.SCROLL) {
+ Main.wm.handleWorkspaceScroll(event);
+ }
+
+ return Clutter.EVENT_PROPAGATE;
+ },
+};