gnome-shell 3.10 compatibility

master
Jens Lody 11 years ago
parent 4f5ec93806
commit d5a4afb914
  1. 2
      data/metadata.json.in
  2. 115
      src/extension.js

@ -2,7 +2,7 @@
"uuid": "@uuid@",
"name": "Top Notification",
"description": "Place shell notifications under the panel instead of above the message-tray",
"shell-version": [ "3.8" ],
"shell-version": [ "3.8", "3.10" ],
"localedir": "@LOCALEDIR@",
"url": "@url@"
}

@ -12,6 +12,8 @@
* The idea comes from 'Shell OSD' gnome-shell extension by
* mpnordland@gmail.com
*/
const ExtensionUtils = imports.misc.extensionUtils;
const Config = imports.misc.config;
const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
const MessageTray = imports.ui.messageTray;
@ -34,6 +36,8 @@ let originalHideNotification = Main.messageTray._hideNotification;
let notificationWidget = Main.messageTray._notificationWidget;
let panel = Main.layoutManager.panelBox;
let originalNotificationWidgetX = notificationWidget.x;
/*
* We need these constants to call Tween with values consistent to the
* MessageTray
@ -89,6 +93,8 @@ let extensionShowNotification = function () {
);
this._notificationBin.child = this._notification.actor;
this._notificationWidget.opacity = 0;
if (!ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
/*
* for .y we use the panel's height, to move it just below the panel.
* we calculate .height every time, to prevent using gnome-shell's startup
@ -106,7 +112,8 @@ let extensionShowNotification = function () {
* font rendering
*/
this._notificationWidget.x = Math.round((panel.width / 2) -
(this._notificationWidget.width / 2));
(this._notificationWidget.width) / 2);
}
this._notificationWidget.show();
this._updateShowingNotification();
let [x, y, mods] = global.get_pointer();
@ -127,11 +134,17 @@ let extensionShowNotification = function () {
* I stripped the original comments out so that my changes (and comments) could
* be highlighted. It's really just a tiny change.
*/
let extensionHideNotification = function() {
let extensionHideNotification = function(animate) {
if (ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
this._notificationFocusGrabber.ungrabFocus();
}
else
{
this._notificationState = State.HIDING;
if (!this._notification) { return; }
this._grabHelper.ungrab({ actor: this._notification.actor });
}
if (this._notificationExpandedId) {
this._notification.disconnect(this._notificationExpandedId);
@ -145,6 +158,34 @@ let extensionHideNotification = function() {
this._notification.disconnect(this._notificationUnfocusedId);
this._notificationUnfocusedId = 0;
}
if (ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
this._useLongerNotificationLeftTimeout = false;
if (this._notificationLeftTimeoutId) {
Mainloop.source_remove(this._notificationLeftTimeoutId);
this._notificationLeftTimeoutId = 0;
this._notificationLeftMouseX = -1;
this._notificationLeftMouseY = -1;
}
if (animate) {
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN, {
y: 0,
opacity: 0,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: this._hideNotificationCompleted,
onCompleteScope: this
});
} else {
Tweener.removeTweens(this._notificationWidget);
this._notificationWidget.y = 0;
this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN;
this._hideNotificationCompleted();
}
}
else
{
this._useLongerTrayLeftTimeout = false;
if (this._trayLeftTimeoutId) {
Mainloop.source_remove(this._trayLeftTimeoutId);
@ -160,13 +201,13 @@ let extensionHideNotification = function() {
this._notificationState = State.HIDDEN;
this._hideNotificationCompleted();
} else {
/*
* We leave the widget.y at panel.height, and not .0; because the
* showing animation is opacity-only.
*
* Can be animated out to .0 if you want; there are no artifacts on
* screen when animating out.
*/
//
// We leave the widget.y at panel.height, and not .0; because the
// showing animation is opacity-only.
//
// Can be animated out to .0 if you want; there are no artifacts on
// screen when animating out.
//
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
{ y: panel.height,
opacity: 0,
@ -177,10 +218,12 @@ let extensionHideNotification = function() {
});
}
}
}
/*
* Copied from MessageTray._updateNotification()
* Copied from MessageTray._updateShowingNotification()
*
* We only change the .y and .x values to move the OSD. We need to copy
* the whole method to prevent the animation from moving the OSD across the
@ -195,11 +238,15 @@ let extensionUpdateShowingNotification = function() {
if (this._notification.urgency == Urgency.CRITICAL ||
this._notification.source.policy.forceExpanded)
this._expandNotification(true);
this._notificationWidget.x = Math.round((panel.width / 2) -
(this._notificationWidget.width) / 2);
/*
* As noted above, panel.height is constant to prevent an artifact,
* so in effect only the opacity changes.
*/
let tweenParams = { opacity: 255,
let tweenParams = {
opacity: 255,
// opacity: 187,
y: panel.height,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
@ -209,6 +256,31 @@ let extensionUpdateShowingNotification = function() {
this._tween(this._notificationWidget, '_notificationState', State.SHOWN, tweenParams);
}
let extensiononNotificationExpanded = function() {
let expandedY = panel.height;
// this._closeButton.y = expandedY;
this._closeButton.show();
log('this._notificationWidget.y = ' + this._notificationWidget.y);
log('this._notificationWidget.height = ' + this._notificationWidget.height);
log('panel.height = ' + panel.height);
// Don't animate the notification to its new position if it has shrunk:
// there will be a very visible "gap" that breaks the illusion.
if (this._notificationWidget.y < expandedY) {
this._notificationWidget.y = expandedY;
} else if (this._notification.y != expandedY) {
// Tween also opacity here, to override a possible tween that's
// currently hiding the notification.
this._tween(this._notificationWidget, '_notificationState', State.SHOWN, {
y: expandedY,
opacity: 255,
time: ANIMATION_TIME,
transition: 'easeOutQuad'
});
log('this._notificationWidget.y = ' + this._notificationWidget.y);
log('this._notificationWidget.height = ' + this._notificationWidget.height);
}
}
/*
* Overload the methods.
@ -225,23 +297,42 @@ function enable() {
Main.messageTray._hideNotification = extensionHideNotification;
Main.messageTray._updateShowingNotification = extensionUpdateShowingNotification;
LayoutManager.untrackChrome(notificationWidget);
if (ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
Main.messageTray._onNotificationExpanded = extensiononNotificationExpanded;
LayoutManager.trayBox.remove_actor(notificationWidget);
Main.uiGroup.add_actor(notificationWidget);
Main.uiGroup.set_child_below_sibling(notificationWidget,
panel);
}
else
{
Main.messageTray.actor.remove_actor(notificationWidget);
panel.add_actor(notificationWidget);
LayoutManager.trackChrome(notificationWidget);
}
}
/*
* Put everything back.
*/
function disable() {
Main.messageTray._onNotificationExpanded = originalExpandMethod;
Main.messageTray._showNotification = originalShowNotification;
Main.messageTray._hideNotification = originalHideNotification;
Main.messageTray._updateShowingNotification = originalUpdateShowingNotification;
if (ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
Main.messageTray._onNotificationExpanded = originalExpandMethod;
notificationWidget.x = originalNotificationWidgetX;
Main.uiGroup.remove_actor(notificationWidget);
Main.layoutManager.trayBox.add_actor(notificationWidget);
}
else
{
LayoutManager.untrackChrome(notificationWidget);
panel.remove_actor(notificationWidget);
Main.messageTray.actor.add_actor(notificationWidget);
LayoutManager.trackChrome(notificationWidget);
}
LayoutManager.trackChrome(notificationWidget);
}

Loading…
Cancel
Save