2025-02-09 23:08:39 +01:00
|
|
|
/**
|
2025-02-09 23:10:52 +01:00
|
|
|
* V-Shell (Vertical Workspaces)
|
2025-02-09 23:08:39 +01:00
|
|
|
* panel.js
|
2025-02-09 23:10:52 +01:00
|
|
|
*
|
2025-02-09 23:08:39 +01:00
|
|
|
* @author GdH <G-dH@github.com>
|
|
|
|
* @copyright 2022 - 2023
|
|
|
|
* @license GPL-3.0
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2025-02-09 23:10:52 +01:00
|
|
|
const { GLib } = imports.gi;
|
2025-02-09 23:08:39 +01:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
2025-02-09 23:10:52 +01:00
|
|
|
const _Util = Me.imports.lib.util;
|
2025-02-09 23:08:39 +01:00
|
|
|
|
|
|
|
const ANIMATION_TIME = imports.ui.overview.ANIMATION_TIME;
|
|
|
|
|
|
|
|
let opt;
|
2025-02-09 23:10:52 +01:00
|
|
|
let _firstRun = true;
|
|
|
|
|
2025-02-09 23:08:39 +01:00
|
|
|
let _showingOverviewConId;
|
|
|
|
let _hidingOverviewConId;
|
|
|
|
let _styleChangedConId;
|
|
|
|
|
|
|
|
function update(reset = false) {
|
2025-02-09 23:10:52 +01:00
|
|
|
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);
|
2025-02-09 23:08:39 +01:00
|
|
|
|
2025-02-09 23:10:52 +01:00
|
|
|
// don't even touch this module if disabled or in potential conflict
|
|
|
|
if (_firstRun && (reset || conflict))
|
|
|
|
return;
|
2025-02-09 23:08:39 +01:00
|
|
|
|
2025-02-09 23:10:52 +01:00
|
|
|
_firstRun = false;
|
2025-02-09 23:08:39 +01:00
|
|
|
|
2025-02-09 23:10:52 +01:00
|
|
|
const panelBox = Main.layoutManager.panelBox;
|
|
|
|
if (reset || !moduleEnabled) {
|
|
|
|
// _disconnectPanel();
|
|
|
|
reset = true;
|
|
|
|
_setPanelPosition(reset);
|
|
|
|
_updateOverviewConnection(reset);
|
2025-02-09 23:08:39 +01:00
|
|
|
_reparentPanel(false);
|
|
|
|
|
2025-02-09 23:10:52 +01:00
|
|
|
_updateStyleChangedConnection(reset);
|
2025-02-09 23:08:39 +01:00
|
|
|
|
|
|
|
panelBox.translation_y = 0;
|
2025-02-09 23:10:52 +01:00
|
|
|
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);
|
2025-02-09 23:08:39 +01:00
|
|
|
} 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);
|
2025-02-09 23:10:52 +01:00
|
|
|
_updateOverviewConnection();
|
2025-02-09 23:08:39 +01:00
|
|
|
} else {
|
|
|
|
// otherwise move the panel below overviewGroup so it can get below workspacesDisplay
|
|
|
|
Main.layoutManager.overviewGroup.set_child_below_sibling(panelBox, Main.overview._overview);
|
2025-02-09 23:10:52 +01:00
|
|
|
_updateOverviewConnection(true);
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
|
|
|
_showPanel(true);
|
|
|
|
} else {
|
|
|
|
// if ws preview bg is disabled, panel can stay in uiGroup
|
|
|
|
_reparentPanel(false);
|
|
|
|
_showPanel(false);
|
2025-02-09 23:10:52 +01:00
|
|
|
_updateOverviewConnection();
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
2025-02-09 23:10:52 +01:00
|
|
|
// _connectPanel();
|
2025-02-09 23:08:39 +01:00
|
|
|
} else if (opt.PANEL_MODE === 2) {
|
2025-02-09 23:10:52 +01:00
|
|
|
_updateOverviewConnection(true);
|
2025-02-09 23:08:39 +01:00
|
|
|
_reparentPanel(false);
|
|
|
|
_showPanel(false);
|
2025-02-09 23:10:52 +01:00
|
|
|
// _connectPanel();
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
2025-02-09 23:10:52 +01:00
|
|
|
_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);
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
|
|
|
|
2025-02-09 23:10:52 +01:00
|
|
|
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');
|
|
|
|
});
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
2025-02-09 23:10:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2025-02-09 23:10:52 +01:00
|
|
|
// return the panel at default position, panel shouldn't cover objects that should be above
|
2025-02-09 23:08:39 +01:00
|
|
|
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!!!!!!!!!!!
|
2025-02-09 23:10:52 +01:00
|
|
|
// 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));*/
|
2025-02-09 23:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2025-02-09 23:10:52 +01:00
|
|
|
},
|
2025-02-09 23:08:39 +01:00
|
|
|
});
|
|
|
|
} 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);
|
2025-02-09 23:10:52 +01:00
|
|
|
},
|
2025-02-09 23:08:39 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|