diff options
Diffstat (limited to '')
-rw-r--r-- | extensions/vertical-workspaces/lib/panel.js (renamed from extensions/vertical-workspaces/panel.js) | 183 |
1 files changed, 101 insertions, 82 deletions
diff --git a/extensions/vertical-workspaces/panel.js b/extensions/vertical-workspaces/lib/panel.js index 2f7143d..3f44ae7 100644 --- a/extensions/vertical-workspaces/panel.js +++ b/extensions/vertical-workspaces/lib/panel.js @@ -1,7 +1,7 @@ /** - * Vertical Workspaces + * V-Shell (Vertical Workspaces) * panel.js - * + * * @author GdH <G-dH@github.com> * @copyright 2022 - 2023 * @license GPL-3.0 @@ -10,92 +10,139 @@ 'use strict'; +const { GLib } = imports.gi; const Main = imports.ui.main; const Me = imports.misc.extensionUtils.getCurrentExtension(); +const _Util = Me.imports.lib.util; const ANIMATION_TIME = imports.ui.overview.ANIMATION_TIME; let opt; +let _firstRun = true; + let _showingOverviewConId; let _hidingOverviewConId; let _styleChangedConId; function update(reset = false) { - opt = Me.imports.settings.opt; - const panelBox = Main.layoutManager.panelBox; - const panelHeight = Main.panel.height; // panelBox height can be 0 after shell start + 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); - const geometry = global.display.get_monitor_geometry(global.display.get_primary_monitor()); - if (reset || opt.PANEL_POSITION_TOP) { - panelBox.set_position(geometry.x, geometry.y); - } else { - panelBox.set_position(geometry.x, geometry.y + geometry.height - panelHeight); - } + // don't even touch this module if disabled or in potential conflict + if (_firstRun && (reset || conflict)) + return; - if (!_styleChangedConId) { - Main.panel.connect('style-changed', ()=> Main.panel.remove_style_pseudo_class('overview')); - } + _firstRun = false; - if (reset || opt.PANEL_MODE === 0) { - //_disconnectPanel(); - _disconnectOverview() + const panelBox = Main.layoutManager.panelBox; + if (reset || !moduleEnabled) { + // _disconnectPanel(); + reset = true; + _setPanelPosition(reset); + _updateOverviewConnection(reset); _reparentPanel(false); - _showPanel(); - if (_styleChangedConId) { - Main.panel.disconnect(_styleChangedConId); - _styleChangedConId = 0; - } + _updateStyleChangedConnection(reset); panelBox.translation_y = 0; - panelBox.opacity = 255; + Main.panel.opacity = 255; + _setPanelStructs(true); + return; + } + + _setPanelPosition(); + _updateStyleChangedConnection(); + + if (opt.PANEL_MODE === 0) { + _updateOverviewConnection(true); + _reparentPanel(false); + 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); } _showPanel(true); } else { // if ws preview bg is disabled, panel can stay in uiGroup _reparentPanel(false); _showPanel(false); - if (!_hidingOverviewConId) - _hidingOverviewConId = Main.overview.connect('hiding', () => { - if ((!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2)) { - _showPanel(false); - } - }); - if (!_showingOverviewConId) - _showingOverviewConId = Main.overview.connect('showing', () => { - if ((!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2)) { - _showPanel(true); - } - }); + _updateOverviewConnection(); } - - _connectPanel(); + // _connectPanel(); } else if (opt.PANEL_MODE === 2) { - _disconnectOverview(); + _updateOverviewConnection(true); _reparentPanel(false); _showPanel(false); - _connectPanel(); + // _connectPanel(); } - _setPanelStructs(reset || opt.PANEL_MODE === 0); + _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 _disconnectOverview() { - if (_hidingOverviewConId) { - Main.overview.disconnect(_hidingOverviewConId); - _hidingOverviewConId = 0; +function _updateStyleChangedConnection(reset = false) { + if (reset) { + if (_styleChangedConId) { + Main.panel.disconnect(_styleChangedConId); + _styleChangedConId = 0; + } + } 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'); + }); } - if (_showingOverviewConId) { - Main.overview.disconnect(_showingOverviewConId); - _showingOverviewConId = 0; +} + +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); + }); + } + if (!_showingOverviewConId) { + _showingOverviewConId = Main.overview.connect('showing', () => { + if (!opt.SHOW_WS_PREVIEW_BG || opt.OVERVIEW_MODE2 || Main.layoutManager.panelBox.translation_y) + _showPanel(true); + }); + } } } @@ -106,7 +153,7 @@ function _reparentPanel(reparent = false) { 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, pane shouldn't cover objects that should be above + // return the panel at default position, panel shouldn't cover objects that should be above Main.layoutManager.uiGroup.insert_child_at_index(panel, 4); } } @@ -120,10 +167,10 @@ function _setPanelStructs(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));*/ + // 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) { @@ -134,9 +181,8 @@ function _showPanel(show = true) { translation_y: 0, onComplete: () => { _setPanelStructs(opt.PANEL_MODE === 0); - } + }, }); - } else { const panelHeight = Main.panel.height; Main.layoutManager.panelBox.ease({ @@ -145,34 +191,7 @@ function _showPanel(show = true) { onComplete: () => { Main.panel.opacity = 0; _setPanelStructs(opt.PANEL_MODE === 0); - } - }); - } -} - -function _connectPanel() { - // not reliable, disabled for now - /*if (!_panelEnterSigId) { - _panelEnterSigId = Main.panel.connect('enter-event', () => { - if (!Main.overview._shown) - _showPanel(true); + }, }); } - if (!_panelLeaveSigId) { - _panelLeaveSigId = Main.panel.connect('leave-event', () => { - if (!Main.overview._shown) - _showPanel(false); - }); - }*/ -} - -function _disconnectPanel() { - /*if (_panelEnterSigId) { - Main.panel.disconnect(_panelEnterSigId); - _panelEnterSigId = 0; - } - if (_panelLeaveSigId) { - Main.panel.disconnect(_panelLeaveSigId); - _panelLeaveSigId = 0; - }*/ } |