/usr/share/gnome-shell/extensions/hidetopbar@mathieu.bidon.ca/extension.js is in gnome-shell-extension-autohidetopbar 20140113-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | //
// Hides the Gnome "top bar" except in overview mode.
// https://extensions.gnome.org/extension/545/hide-top-bar/
// https://github.com/mlutfy/hidetopbar
//
// See README for more information.
//
const Main = imports.ui.main;
const Layout = imports.ui.layout;
const Meta = imports.gi.Meta;
const Tweener = imports.ui.tweener;
const Settings = imports.misc.extensionUtils.getCurrentExtension()
.imports.convenience.getSettings();
const PANEL_ACTOR = Main.panel.actor;
const PANEL_BOX = PANEL_ACTOR.get_parent();
let _panelHeight = PANEL_ACTOR.get_height();
let _showEvent = 0;
let _hideEvent = 0;
let _stgsEventAnim = 0;
let _stgsEventAnim2 = 0;
let _stgsEventHotCorner = 0;
let _stgsEventSensitive = 0;
let _stgsEventOverv = 0;
let _stgsEventPressTime = 0;
let _stgsEventPressThresh = 0;
let _leaveEvent = 0;
let _menuEvent = 0;
let _blockerMenu = 0;
let _panelPressure = 0;
let _panelBarrier = 0;
let _settingsHotCorner = Settings.get_boolean('hot-corner');
let _settingsMouseSensitive = Settings.get_boolean('mouse-sensitive');
let _settingsShowOverview = Settings.get_boolean('mouse-triggers-overview');
let _settingsAnimTimeOverv = Settings.get_double('animation-time-overview');
let _settingsAnimTimeAutoh = Settings.get_double('animation-time-autohide');
function _hidePanel(animationTime, trigger) {
_panelHeight = PANEL_ACTOR.get_height();
if(global.get_pointer()[1] < _panelHeight && trigger == "mouse-left") {
return;
}
let x = Number(_settingsHotCorner);
PANEL_BOX.height = x;
Tweener.addTween(PANEL_BOX, {
y: x - _panelHeight,
time: animationTime,
transition: 'easeOutQuad',
onComplete: function() { PANEL_ACTOR.set_opacity(x*255); }
});
}
function _showPanel(animationTime, trigger) {
if(trigger == "mouse-enter" && _settingsShowOverview)
Main.overview.show();
if(PANEL_BOX.y > 1-_panelHeight) return;
PANEL_BOX.height = _panelHeight;
PANEL_ACTOR.set_opacity(255);
Tweener.addTween(PANEL_BOX, {
y: 0,
time: animationTime,
transition: 'easeOutQuad'
});
}
function _handleMenus() {
if(!Main.overview.visible) {
let blocker = Main.panel.menuManager.activeMenu;
if(blocker == null) {
_hidePanel(_settingsAnimTimeAutoh, "mouse-left");
} else {
_blockerMenu = blocker;
_menuEvent = _blockerMenu.connect('open-state-changed', function(menu, open){
if(!open) {
_blockerMenu.disconnect(_menuEvent);
_menuEvent = 0; _blockerMenu = 0;
_handleMenus();
}
});
}
}
}
function _updateMouseSensitive() {
_settingsMouseSensitive = Settings.get_boolean('mouse-sensitive');
if(_settingsMouseSensitive) {
_disable_mouse_sensitive();
_leaveEvent = PANEL_ACTOR.connect('leave-event', _handleMenus);
_initPressureBarrier();
} else _disable_mouse_sensitive();
}
function _disable_mouse_sensitive() {
if(_panelBarrier && _panelPressure) {
_panelPressure.removeBarrier(_panelBarrier);
_panelBarrier.destroy();
}
if(_leaveEvent) PANEL_ACTOR.disconnect(_leaveEvent);
}
function _initPressureBarrier() {
_panelPressure = new Layout.PressureBarrier(
Settings.get_int('pressure-threshold'),
Settings.get_int('pressure-timeout'),
imports.gi.Shell.KeyBindingMode.NORMAL
);
_panelPressure.setEventFilter(function(event) {
if (event.grabbed && Main.modalCount == 0)
return true;
return false;
});
_panelPressure.connect('trigger', function(barrier) {
if (Main.layoutManager.primaryMonitor.inFullscreen)
return;
_showPanel(_settingsAnimTimeAutoh, "mouse-enter");
});
let monitor = Main.layoutManager.primaryMonitor;
_panelBarrier = new Meta.Barrier({ display: global.display,
x1: monitor.x, x2: monitor.x + monitor.width,
y1: monitor.y, y2: monitor.y,
directions: Meta.BarrierDirection.POSITIVE_Y });
_panelPressure.addBarrier(_panelBarrier);
}
function _setup_settings_handler() {
_stgsEventAnim = Settings.connect('changed::animation-time-overview',
function() {
_settingsAnimTimeOverv = Settings.get_double('animation-time-overview');
});
_stgsEventAnim2 = Settings.connect('changed::animation-time-autohide',
function() {
_settingsAnimTimeAutoh = Settings.get_double('animation-time-autohide');
});
_stgsEventOverv = Settings.connect('changed::mouse-triggers-overview',
function() {
_settingsShowOverview = Settings.get_boolean('mouse-triggers-overview');
});
_stgsEventHotCorner = Settings.connect('changed::hot-corner', function() {
_settingsHotCorner = Settings.get_boolean('hot-corner');
_hidePanel(0.1);
});
_stgsEventPressTime = Settings.connect('changed::pressure-timeout', _updateMouseSensitive);
_stgsEventPressThresh = Settings.connect('changed::pressure-threshold', _updateMouseSensitive);
_stgsEventSensitive = Settings.connect('changed::mouse-sensitive', _updateMouseSensitive);
}
function _disconnect_settings_handler() {
if(_stgsEventAnim) Settings.disconnect(_stgsEventAnim);
if(_stgsEventAnim2) Settings.disconnect(_stgsEventAnim2);
if(_stgsEventOverv) Settings.disconnect(_stgsEventOverv);
if(_stgsEventHotCorner) Settings.disconnect(_stgsEventHotCorner);
if(_stgsEventPressThresh) Settings.disconnect(_stgsEventPressThresh);
if(_stgsEventPressTime) Settings.disconnect(_stgsEventPressTime);
if(_stgsEventSensitive) Settings.disconnect(_stgsEventSensitive);
}
function init() { }
function enable() {
Main.layoutManager.removeChrome(PANEL_BOX);
Main.layoutManager.addChrome(PANEL_BOX, { affectsStruts: false });
_showEvent = Main.overview.connect('showing', function() {
_showPanel(_settingsAnimTimeOverv);
});
_hideEvent = Main.overview.connect('hiding', function() {
_hidePanel(_settingsAnimTimeOverv);
});
_setup_settings_handler();
_updateMouseSensitive();
_hidePanel(0.1);
}
function disable() {
Main.layoutManager.removeChrome(PANEL_BOX);
Main.layoutManager.addChrome(PANEL_BOX, { affectsStruts: true });
if(_showEvent) Main.overview.disconnect(_showEvent);
if(_hideEvent) Main.overview.disconnect(_hideEvent);
_disconnect_settings_handler();
_disable_mouse_sensitive();
_showPanel(0.1);
}
|