gnome-shell 3.10 compatibility

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

@ -2,7 +2,7 @@
"uuid": "@uuid@", "uuid": "@uuid@",
"name": "Top Notification", "name": "Top Notification",
"description": "Place shell notifications under the panel instead of above the message-tray", "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@", "localedir": "@LOCALEDIR@",
"url": "@url@" "url": "@url@"
} }

@ -12,6 +12,8 @@
* The idea comes from 'Shell OSD' gnome-shell extension by * The idea comes from 'Shell OSD' gnome-shell extension by
* mpnordland@gmail.com * mpnordland@gmail.com
*/ */
const ExtensionUtils = imports.misc.extensionUtils;
const Config = imports.misc.config;
const Main = imports.ui.main; const Main = imports.ui.main;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
const MessageTray = imports.ui.messageTray; const MessageTray = imports.ui.messageTray;
@ -34,6 +36,8 @@ let originalHideNotification = Main.messageTray._hideNotification;
let notificationWidget = Main.messageTray._notificationWidget; let notificationWidget = Main.messageTray._notificationWidget;
let panel = Main.layoutManager.panelBox; let panel = Main.layoutManager.panelBox;
let originalNotificationWidgetX = notificationWidget.x;
/* /*
* We need these constants to call Tween with values consistent to the * We need these constants to call Tween with values consistent to the
* MessageTray * MessageTray
@ -89,24 +93,27 @@ let extensionShowNotification = function () {
); );
this._notificationBin.child = this._notification.actor; this._notificationBin.child = this._notification.actor;
this._notificationWidget.opacity = 0; this._notificationWidget.opacity = 0;
/*
* for .y we use the panel's height, to move it just below the panel. if (!ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
* we calculate .height every time, to prevent using gnome-shell's startup /*
* panel height before the themes are loaded. * 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
* If you set this to .0, the OSD is animated (Tweened) in from outside * panel height before the themes are loaded.
* the screen, but the very first frame moves *all* windows down to make *
* space for the OSD. Subsequent frames moves the windows back. * If you set this to .0, the OSD is animated (Tweened) in from outside
* * the screen, but the very first frame moves *all* windows down to make
* I don't know how to fix that. * space for the OSD. Subsequent frames moves the windows back.
*/ *
this._notificationWidget.y = panel.height; * I don't know how to fix that.
/* */
* for .x we Math.round() to prevent 1/2 pixels; which can cause blurry this._notificationWidget.y = panel.height;
* font rendering /*
*/ * for .x we Math.round() to prevent 1/2 pixels; which can cause blurry
this._notificationWidget.x = Math.round((panel.width / 2) - * font rendering
(this._notificationWidget.width / 2)); */
this._notificationWidget.x = Math.round((panel.width / 2) -
(this._notificationWidget.width) / 2);
}
this._notificationWidget.show(); this._notificationWidget.show();
this._updateShowingNotification(); this._updateShowingNotification();
let [x, y, mods] = global.get_pointer(); 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 * I stripped the original comments out so that my changes (and comments) could
* be highlighted. It's really just a tiny change. * 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; this._notificationState = State.HIDING;
if (!this._notification) { return; } if (!this._notification) { return; }
this._grabHelper.ungrab({ actor: this._notification.actor }); this._grabHelper.ungrab({ actor: this._notification.actor });
}
if (this._notificationExpandedId) { if (this._notificationExpandedId) {
this._notification.disconnect(this._notificationExpandedId); this._notification.disconnect(this._notificationExpandedId);
@ -145,42 +158,72 @@ let extensionHideNotification = function() {
this._notification.disconnect(this._notificationUnfocusedId); this._notification.disconnect(this._notificationUnfocusedId);
this._notificationUnfocusedId = 0; this._notificationUnfocusedId = 0;
} }
this._useLongerTrayLeftTimeout = false; if (ExtensionUtils.versionCheck(['3.9', '3.10'], Config.PACKAGE_VERSION)) {
if (this._trayLeftTimeoutId) { this._useLongerNotificationLeftTimeout = false;
Mainloop.source_remove(this._trayLeftTimeoutId); if (this._notificationLeftTimeoutId) {
this._trayLeftTimeoutId = 0; Mainloop.source_remove(this._notificationLeftTimeoutId);
this._trayLeftMouseX = -1; this._notificationLeftTimeoutId = 0;
this._trayLeftMouseY = -1; 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);
this._trayLeftTimeoutId = 0;
this._trayLeftMouseX = -1;
this._trayLeftMouseY = -1;
}
if (this._notificationRemoved) { if (this._notificationRemoved) {
Tweener.removeTweens(this._notificationWidget); Tweener.removeTweens(this._notificationWidget);
this._notificationWidget.y = this.actor.height; this._notificationWidget.y = this.actor.height;
this._notificationWidget.opacity = 0; this._notificationWidget.opacity = 0;
this._notificationState = State.HIDDEN; this._notificationState = State.HIDDEN;
this._hideNotificationCompleted(); this._hideNotificationCompleted();
} else { } else {
/* //
* We leave the widget.y at panel.height, and not .0; because the // We leave the widget.y at panel.height, and not .0; because the
* showing animation is opacity-only. // showing animation is opacity-only.
* //
* Can be animated out to .0 if you want; there are no artifacts on // Can be animated out to .0 if you want; there are no artifacts on
* screen when animating out. // screen when animating out.
*/ //
this._tween(this._notificationWidget, '_notificationState', State.HIDDEN, this._tween(this._notificationWidget, '_notificationState', State.HIDDEN,
{ y: panel.height, { y: panel.height,
opacity: 0, opacity: 0,
time: ANIMATION_TIME, time: ANIMATION_TIME,
transition: 'easeOutQuad', transition: 'easeOutQuad',
onComplete: this._hideNotificationCompleted, onComplete: this._hideNotificationCompleted,
onCompleteScope: this onCompleteScope: this
}); });
}
} }
} }
/* /*
* Copied from MessageTray._updateNotification() * Copied from MessageTray._updateNotification()
* Copied from MessageTray._updateShowingNotification()
* *
* We only change the .y and .x values to move the OSD. We need to copy * 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 * the whole method to prevent the animation from moving the OSD across the
@ -190,25 +233,54 @@ let extensionHideNotification = function() {
* be highlighted. It's really just a tiny change. * be highlighted. It's really just a tiny change.
*/ */
let extensionUpdateShowingNotification = function() { let extensionUpdateShowingNotification = function() {
this._notification.acknowledged = true; this._notification.acknowledged = true;
this._notification.playSound(); this._notification.playSound();
if (this._notification.urgency == Urgency.CRITICAL || if (this._notification.urgency == Urgency.CRITICAL ||
this._notification.source.policy.forceExpanded) this._notification.source.policy.forceExpanded)
this._expandNotification(true); this._expandNotification(true);
/* this._notificationWidget.x = Math.round((panel.width / 2) -
* As noted above, panel.height is constant to prevent an artifact, (this._notificationWidget.width) / 2);
* so in effect only the opacity changes. /*
*/ * As noted above, panel.height is constant to prevent an artifact,
let tweenParams = { opacity: 255, * so in effect only the opacity changes.
y: panel.height, */
time: ANIMATION_TIME, let tweenParams = {
transition: 'easeOutQuad', opacity: 255,
onComplete: this._showNotificationCompleted, // opacity: 187,
onCompleteScope: this y: panel.height,
}; time: ANIMATION_TIME,
this._tween(this._notificationWidget, '_notificationState', State.SHOWN, tweenParams); transition: 'easeOutQuad',
onComplete: this._showNotificationCompleted,
onCompleteScope: this
};
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. * Overload the methods.
@ -221,13 +293,24 @@ let extensionUpdateShowingNotification = function() {
* lost. * lost.
*/ */
function enable() { function enable() {
Main.messageTray._showNotification = extensionShowNotification; Main.messageTray._showNotification = extensionShowNotification;
Main.messageTray._hideNotification = extensionHideNotification; Main.messageTray._hideNotification = extensionHideNotification;
Main.messageTray._updateShowingNotification = extensionUpdateShowingNotification; Main.messageTray._updateShowingNotification = extensionUpdateShowingNotification;
LayoutManager.untrackChrome(notificationWidget); 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); Main.messageTray.actor.remove_actor(notificationWidget);
panel.add_actor(notificationWidget); panel.add_actor(notificationWidget);
LayoutManager.trackChrome(notificationWidget); LayoutManager.trackChrome(notificationWidget);
}
} }
@ -235,13 +318,21 @@ function enable() {
* Put everything back. * Put everything back.
*/ */
function disable() { function disable() {
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; Main.messageTray._onNotificationExpanded = originalExpandMethod;
Main.messageTray._showNotification = originalShowNotification; notificationWidget.x = originalNotificationWidgetX;
Main.messageTray._hideNotification = originalHideNotification; Main.uiGroup.remove_actor(notificationWidget);
Main.messageTray._updateShowingNotification = originalUpdateShowingNotification; Main.layoutManager.trayBox.add_actor(notificationWidget);
LayoutManager.untrackChrome(notificationWidget); }
panel.remove_actor(notificationWidget); else
Main.messageTray.actor.add_actor(notificationWidget); {
LayoutManager.trackChrome(notificationWidget); LayoutManager.untrackChrome(notificationWidget);
} panel.remove_actor(notificationWidget);
Main.messageTray.actor.add_actor(notificationWidget);
}
LayoutManager.trackChrome(notificationWidget);
}

Loading…
Cancel
Save