@ -37,18 +37,18 @@ const PANEL_OSD_TEST_NOTIFICATION = 'test-notification';
* Save MessageTray 's original methods. We' re going to change these
* Save MessageTray 's original methods. We' re going to change these
* in our extension to move the OSD .
* in our extension to move the OSD .
* /
* /
let originalExpandMethod = Main . messageTray . _onNotificationExpanded ;
let originalExpandMethod ;
let originalShowNotification = Main . messageTray . _showNotification ;
let originalShowNotification ;
let originalUpdateShowingNotification = Main . messageTray . _updateShowingNotification ;
let originalUpdateShowingNotification ;
let originalHideNotification = Main . messageTray . _hideNotification ;
let originalHideNotification ;
/ *
/ *
* The widget we ' re interested in
* The widget we ' re interested in
* /
* /
let notificationWidget = Main . messageTray . _notificationWidget ;
let notificationWidget ;
let panel = Main . layoutManager . panelBox ;
let panel ;
let originalNotificationWidgetX = notificationWidget . x ;
let originalNotificationWidgetX ;
/ *
/ *
* We need these constants to call Tween with values consistent to the
* We need these constants to call Tween with values consistent to the
@ -84,6 +84,7 @@ let loadConfig = function() {
if ( getTestNotification ( ) ) {
if ( getTestNotification ( ) ) {
if ( showTestNotificationTimeout !== undefined )
if ( showTestNotificationTimeout !== undefined )
Mainloop . source _remove ( showTestNotificationTimeout ) ;
Mainloop . source _remove ( showTestNotificationTimeout ) ;
showTestNotificationTimeout = Mainloop . timeout _add ( getTestDelay ( ) , Lang . bind ( this , function ( ) {
showTestNotificationTimeout = Mainloop . timeout _add ( getTestDelay ( ) , Lang . bind ( this , function ( ) {
Main . notify ( "Panel OSD" , _ ( "This is just a multiline test-message to show where the notification will be placed and to test expansion (showing details)." ) ) ;
Main . notify ( "Panel OSD" , _ ( "This is just a multiline test-message to show where the notification will be placed and to test expansion (showing details)." ) ) ;
return false ;
return false ;
@ -137,21 +138,40 @@ let setTestNotification = function(v) {
* /
* /
let extensionShowNotification = function ( ) {
let extensionShowNotification = function ( ) {
this . _notification = this . _notificationQueue . shift ( ) ;
this . _notification = this . _notificationQueue . shift ( ) ;
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
this . emit ( 'queue-changed' ) ;
}
this . _userActiveWhileNotificationShown = this . idleMonitor . get _idletime ( ) <= IDLE _TIME ;
this . _userActiveWhileNotificationShown = this . idleMonitor . get _idletime ( ) <= IDLE _TIME ;
if ( ExtensionUtils . versionCheck ( [ '3.6' ] , Config . PACKAGE _VERSION ) ) {
this . _idleMonitorWatchId = this . idleMonitor . add _watch ( IDLE _TIME ,
Lang . bind ( this , this . _onIdleMonitorWatch ) ) ;
}
else
{
if ( ! this . _userActiveWhileNotificationShown ) {
if ( ! this . _userActiveWhileNotificationShown ) {
// If the user isn't active, set up a watch to let us know
// If the user isn't active, set up a watch to let us know
// when the user becomes active.
// when the user becomes active.
this . idleMonitor . add _user _active _watch ( Lang . bind ( this , this . _onIdleMonitorBecameActive ) ) ;
this . idleMonitor . add _user _active _watch ( Lang . bind ( this , this . _onIdleMonitorBecameActive ) ) ;
}
}
}
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
this . _banner = this . _notification . createBanner ( ) ;
this . _bannerClickedId = this . _banner . connect ( 'done-displaying' ,
Lang . bind ( this , this . _escapeTray ) ) ;
this . _bannerUnfocusedId = this . _banner . connect ( 'unfocused' , Lang . bind ( this , function ( ) {
this . _updateState ( ) ;
} ) ) ;
this . _bannerBin . add _actor ( this . _banner . actor ) ;
this . _bannerBin . _opacity = 0 ;
this . _bannerBin . opacity = 0 ;
let yTop = ( Main . layoutManager . bottomMonitor . y + Main . layoutManager . bottomMonitor . height ) ;
let yBottom = this . _banner . actor . height ;
this . _bannerBin . y = - ( yTop - yBottom ) * getY _position ( ) / 100 + yBottom ;
this . _bannerBin . y = - this . _banner . actor . height ;
this . actor . show ( ) ;
} else
{
this . _notificationClickedId = this . _notification . connect ( 'done-displaying' ,
this . _notificationClickedId = this . _notification . connect ( 'done-displaying' ,
Lang . bind ( this , this . _escapeTray ) ) ;
Lang . bind ( this , this . _escapeTray ) ) ;
this . _notificationUnfocusedId = this . _notification . connect ( 'unfocused' , Lang . bind ( this , function ( ) {
this . _notificationUnfocusedId = this . _notification . connect ( 'unfocused' , Lang . bind ( this , function ( ) {
@ -170,6 +190,7 @@ let extensionShowNotification = function() {
this . _notificationWidget . show ( ) ;
this . _notificationWidget . show ( ) ;
}
this . _updateShowingNotification ( ) ;
this . _updateShowingNotification ( ) ;
@ -186,7 +207,7 @@ let extensionShowNotification = function() {
// the mouse is moving towards it or within it.
// the mouse is moving towards it or within it.
this . _lastSeenMouseX = x ;
this . _lastSeenMouseX = x ;
this . _lastSeenMouseY = y ;
this . _lastSeenMouseY = y ;
if ( ExtensionUtils . versionCheck ( [ '3.14' ] , Config . PACKAGE _VERSION ) ) {
if ( ExtensionUtils . versionCheck ( [ '3.14' , '3.16' ] , Config . PACKAGE _VERSION ) ) {
this . _resetNotificationLeftTimeout ( ) ;
this . _resetNotificationLeftTimeout ( ) ;
}
}
} ;
} ;
@ -200,64 +221,36 @@ let extensionShowNotification = function() {
* entire screen .
* entire screen .
* /
* /
let extensionHideNotification = function ( animate ) {
let extensionHideNotification = function ( animate ) {
if ( ExtensionUtils . versionCheck ( [ '3.6' , '3.8' ] , Config . PACKAGE _VERSION ) ) {
this . _notificationFocusGrabber . ungrabFocus ( ) ;
// HACK!
// There seems to be a reentrancy issue in calling .ungrab() here,
// which causes _updateState to be called before _notificationState
// becomes HIDING. That hides the notification again, nullifying the
// object but not setting _notificationState (and that's the weird part)
// As then _notificationState is stuck into SHOWN but _notification
// is null, every new _updateState fails and the message tray is
// lost forever.
//
// See more at https://bugzilla.gnome.org/show_bug.cgi?id=683986
this . _notificationState = State . HIDING ;
this . _grabHelper . ungrab ( { actor : this . _notification . actor } ) ;
let yPos ;
}
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
if ( getY _position ( ) < 50 )
yPos = Main . layoutManager . bottomMonitor . y + Main . layoutManager . bottomMonitor . height ;
else
else
{
yPos = - this . _bannerBin . height ;
this . _notificationFocusGrabber . ungrabFocus ( ) ;
if ( this . _bannerClickedId ) {
this . _banner . disconnect ( this . _bannerClickedId ) ;
this . _bannerClickedId = 0 ;
}
if ( this . _bannerUnfocusedId ) {
this . _banner . disconnect ( this . _bannerUnfocusedId ) ;
this . _bannerUnfocusedId = 0 ;
}
}
} else
{
if ( this . _notificationExpandedId ) {
if ( this . _notificationExpandedId ) {
this . _notification . disconnect ( this . _notificationExpandedId ) ;
this . _notification . disconnect ( this . _notificationExpandedId ) ;
this . _notificationExpandedId = 0 ;
this . _notificationExpandedId = 0 ;
}
}
// JRL changes begin
// JRL changes begin
let yPos ;
if ( getY _position ( ) < 50 )
if ( getY _position ( ) < 50 )
yPos = this . actor . height ;
yPos = this . actor . height ;
else
else
yPos = - ( Main . layoutManager . bottomMonitor . y + Main . layoutManager . bottomMonitor . height ) ;
yPos = - ( Main . layoutManager . bottomMonitor . y + Main . layoutManager . bottomMonitor . height ) ;
// JRL changes end
// JRL changes end
if ( ExtensionUtils . versionCheck ( [ '3.6' ] , Config . PACKAGE _VERSION ) ) {
if ( this . _notificationRemoved ) {
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
this . _notificationWidget . y = yPos ;
// JRL changes end
this . _notificationWidget . opacity = 0 ;
this . _notificationState = State . HIDDEN ;
this . _hideNotificationCompleted ( ) ;
} else {
this . _tween ( this . _notificationWidget , '_notificationState' , State . HIDDEN ,
// JRL changes begin
//{ y: this.actor.height,
{ y : yPos ,
// JRL changes end
opacity : 0 ,
time : ANIMATION _TIME ,
transition : 'easeOutQuad' ,
onComplete : this . _hideNotificationCompleted ,
onCompleteScope : this
} ) ;
}
}
else
{
if ( this . _notificationClickedId ) {
if ( this . _notificationClickedId ) {
this . _notification . disconnect ( this . _notificationClickedId ) ;
this . _notification . disconnect ( this . _notificationClickedId ) ;
this . _notificationClickedId = 0 ;
this . _notificationClickedId = 0 ;
@ -266,43 +259,9 @@ let extensionHideNotification = function(animate) {
this . _notification . disconnect ( this . _notificationUnfocusedId ) ;
this . _notification . disconnect ( this . _notificationUnfocusedId ) ;
this . _notificationUnfocusedId = 0 ;
this . _notificationUnfocusedId = 0 ;
}
}
if ( ExtensionUtils . versionCheck ( [ '3.8' ] , Config . PACKAGE _VERSION ) ) {
this . _useLongerTrayLeftTimeout = false ;
if ( this . _trayLeftTimeoutId ) {
Mainloop . source _remove ( this . _trayLeftTimeoutId ) ;
this . _trayLeftTimeoutId = 0 ;
this . _trayLeftMouseX = - 1 ;
this . _trayLeftMouseY = - 1 ;
}
}
if ( this . _notificationRemoved ) {
if ( ExtensionUtils . versionCheck ( [ '3.14' , '3.16' ] , Config . PACKAGE _VERSION ) ) {
Tweener . removeTweens ( this . _notificationWidget ) ;
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
this . _notificationWidget . y = yPos ;
// JRL changes end
this . _notificationWidget . opacity = 0 ;
this . _notificationState = State . HIDDEN ;
this . _hideNotificationCompleted ( ) ;
} else {
this . _tween ( this . _notificationWidget , '_notificationState' , State . HIDDEN ,
// JRL changes begin
//{ y: this.actor.height,
{ y : yPos ,
// JRL changes end
opacity : 0 ,
time : ANIMATION _TIME ,
transition : 'easeOutQuad' ,
onComplete : this . _hideNotificationCompleted ,
onCompleteScope : this
} ) ;
}
}
else
{
if ( ExtensionUtils . versionCheck ( [ '3.14' ] , Config . PACKAGE _VERSION ) ) {
this . _resetNotificationLeftTimeout ( ) ;
this . _resetNotificationLeftTimeout ( ) ;
}
}
else
else
@ -315,10 +274,20 @@ let extensionHideNotification = function(animate) {
}
}
}
}
// JRL changes begin
let theNotification ;
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
theNotification = this . _bannerBin ;
} else
{
theNotification = this . _notificationWidget ;
}
// JRL changes end
if ( animate ) {
if ( animate ) {
this . _tween ( this . _notificationWidget , '_notificationState' , State . HIDDEN ,
// JRL changes begin
// JRL changes begin
//{ y: this.actor.height,
this . _tween ( theNotification , '_notificationState' , State . HIDDEN ,
{ y : yPos ,
{ y : yPos ,
// JRL changes end
// JRL changes end
opacity : 0 ,
opacity : 0 ,
@ -328,17 +297,14 @@ let extensionHideNotification = function(animate) {
onCompleteScope : this
onCompleteScope : this
} ) ;
} ) ;
} else {
} else {
Tweener . removeTweens ( this . _notificationWidget ) ;
// JRL changes begin
// JRL changes begin
//this._notificationWidget.y = this.actor.height;
Tweener . removeTweens ( theNotification ) ;
this . _notificationWidget . y = yPos ;
theNotification . y = yPos ;
theNotification . opacity = 0 ;
// JRL changes end
// JRL changes end
this . _notificationWidget . opacity = 0 ;
this . _notificationState = State . HIDDEN ;
this . _notificationState = State . HIDDEN ;
this . _hideNotificationCompleted ( ) ;
this . _hideNotificationCompleted ( ) ;
}
}
}
}
} ;
} ;
@ -353,6 +319,7 @@ let extensionHideNotification = function(animate) {
let extensionUpdateShowingNotification = function ( ) {
let extensionUpdateShowingNotification = function ( ) {
// JRL changes begin
// JRL changes begin
// first reset the border-radius to the default
// first reset the border-radius to the default
if ( ! ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
this . _notification . _table . set _style ( 'border-radius:;' ) ;
this . _notification . _table . set _style ( 'border-radius:;' ) ;
if ( getY _position ( ) > 0.1 )
if ( getY _position ( ) > 0.1 )
{
{
@ -372,19 +339,9 @@ let extensionUpdateShowingNotification = function() {
}
}
this . _notification . _table . set _style ( _ ( 'border-radius: %dpx %dpx %dpx %dpx;' ) . format ( tl , tr , bl , br ) ) ;
this . _notification . _table . set _style ( _ ( 'border-radius: %dpx %dpx %dpx %dpx;' ) . format ( tl , tr , bl , br ) ) ;
}
}
}
// JRL changes end
// JRL changes end
this . _notification . acknowledged = true ;
this . _notification . acknowledged = true ;
if ( ExtensionUtils . versionCheck ( [ '3.6' ] , Config . PACKAGE _VERSION ) ) {
// We auto-expand notifications with CRITICAL urgency.
// JRL changes begin
// if (this._notification.urgency == Urgency.CRITICAL)
if ( this . _notification . urgency == Urgency . CRITICAL ||
getForce _expand ( ) )
// JRL changes end
this . _expandNotification ( true ) ;
}
else
{
this . _notification . playSound ( ) ;
this . _notification . playSound ( ) ;
// We auto-expand notifications with CRITICAL urgency, or for which the relevant setting
// We auto-expand notifications with CRITICAL urgency, or for which the relevant setting
// is on in the control center.
// is on in the control center.
@ -393,25 +350,53 @@ let extensionUpdateShowingNotification = function() {
getForce _expand ( ) ||
getForce _expand ( ) ||
// JRL changes end
// JRL changes end
this . _notification . source . policy . forceExpanded )
this . _notification . source . policy . forceExpanded )
{
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) )
this . _expandBanner ( true ) ;
else
this . _expandNotification ( true ) ;
this . _expandNotification ( true ) ;
}
}
// JRL changes begin
// JRL changes begin
let theNotification ;
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
theNotification = this . _bannerBin ;
} else
{
theNotification = this . _notificationWidget ;
}
// use panel's y and height property to determine the bottom of the top-panel.
// use panel's y and height property to determine the bottom of the top-panel.
// needed because the "hide top bar" and "hide top panel" use different approaches to hide the
// needed because the "hide top bar" and "hide top panel" use different approaches to hide the
// top bar.
// top bar.
// "hide top panel" keeps the height and just moves the panel out of the visible area, so using
// "hide top panel" keeps the height and just moves the panel out of the visible area, so using
// the panels-height is not enough.
// the panels-height is not enough.
let yPos ;
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
let yTop = Main . layoutManager . bottomMonitor . y
if ( Main . layoutManager . bottomMonitor == Main . layoutManager . primaryMonitor )
yTop += ( panel . y + panel . height ) ;
let yBottom = theNotification . height ;
yPos = ( Main . layoutManager . bottomMonitor . height - yTop - yBottom ) * ( 100 - getY _position ( ) ) / 100 ;
if ( yPos > ( Main . layoutManager . bottomMonitor . height - theNotification . height ) )
yPos = Main . layoutManager . bottomMonitor . height - theNotification . height ;
} else
{
let yTop = - ( Main . layoutManager . bottomMonitor . y + Main . layoutManager . bottomMonitor . height ) ;
let yTop = - ( Main . layoutManager . bottomMonitor . y + Main . layoutManager . bottomMonitor . height ) ;
if ( Main . layoutManager . bottomMonitor == Main . layoutManager . primaryMonitor )
if ( Main . layoutManager . bottomMonitor == Main . layoutManager . primaryMonitor )
yTop += ( panel . y + panel . height ) ;
yTop += ( panel . y + panel . height ) ;
if ( yTop < ( - Main . layoutManager . bottomMonitor . height ) )
if ( yTop < ( - Main . layoutManager . bottomMonitor . height ) )
yTop = - Main . layoutManager . bottomMonitor . height ;
yTop = - Main . layoutManager . bottomMonitor . height ;
let yBottom = - this . _notificationWidget . height ;
let yBottom = - theNotification . height ;
let yPos = ( yTop - yBottom ) * getY _position ( ) / 100 + yBottom ;
yPos = ( yTop - yBottom ) * getY _position ( ) / 100 + yBottom ;
//
//
this . _notificationWidget . x = ( Main . layoutManager . bottomMonitor . width - this . _notificationWidget . width ) * ( getX _position ( ) - 50 ) / 50 ;
}
theNotification . x = ( Main . layoutManager . bottomMonitor . width - theNotification . width ) * ( getX _position ( ) - 50 ) / 50 ;
// JRL changes end
// JRL changes end
// We tween all notifications to full opacity. This ensures that both new notifications and
// We tween all notifications to full opacity. This ensures that both new notifications and
// notifications that might have been in the process of hiding get full opacity.
// notifications that might have been in the process of hiding get full opacity.
@ -424,9 +409,21 @@ let extensionUpdateShowingNotification = function() {
// We use this._showNotificationCompleted() onComplete callback to extend the time the updated
// We use this._showNotificationCompleted() onComplete callback to extend the time the updated
// notification is being shown.
// notification is being shown.
let tweenParams = { opacity : 255 ,
let tweenParams ;
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
tweenParams = { _opacity : 255 ,
y : yPos ,
time : ANIMATION _TIME ,
transition : 'easeOutBack' ,
onUpdate : this . _clampOpacity ,
onUpdateScope : this ,
onComplete : this . _showNotificationCompleted ,
onCompleteScope : this
} ;
} else
{
tweenParams = { opacity : 255 ,
// JRL changes begin
// JRL changes begin
//y: -this._notificationWidget.height,
y : yPos ,
y : yPos ,
// JRL changes end
// JRL changes end
time : ANIMATION _TIME ,
time : ANIMATION _TIME ,
@ -434,8 +431,9 @@ let extensionUpdateShowingNotification = function() {
onComplete : this . _showNotificationCompleted ,
onComplete : this . _showNotificationCompleted ,
onCompleteScope : this
onCompleteScope : this
} ;
} ;
}
this . _tween ( this . _notificationWidget , '_notificationState' , State . SHOWN , tweenParams ) ;
this . _tween ( theNotification , '_notificationState' , State . SHOWN , tweenParams ) ;
} ;
} ;
/ *
/ *
@ -496,6 +494,23 @@ let extensiononNotificationExpanded = function() {
* Overload the methods .
* Overload the methods .
* /
* /
function enable ( ) {
function enable ( ) {
if ( ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
notificationWidget = Main . messageTray . _bannerBin ;
} else
{
notificationWidget = Main . messageTray . _notificationWidget ;
originalExpandMethod = Main . messageTray . _onNotificationExpanded ;
}
originalShowNotification = Main . messageTray . _showNotification ;
originalUpdateShowingNotification = Main . messageTray . _updateShowingNotification ;
originalHideNotification = Main . messageTray . _hideNotification ;
panel = Main . layoutManager . panelBox ;
originalNotificationWidgetX = notificationWidget . x ;
Main . messageTray . _showNotification = extensionShowNotification ;
Main . messageTray . _showNotification = extensionShowNotification ;
Main . messageTray . _hideNotification = extensionHideNotification ;
Main . messageTray . _hideNotification = extensionHideNotification ;
Main . messageTray . _updateShowingNotification = extensionUpdateShowingNotification ;
Main . messageTray . _updateShowingNotification = extensionUpdateShowingNotification ;
@ -524,5 +539,7 @@ function disable() {
Main . messageTray . _showNotification = originalShowNotification ;
Main . messageTray . _showNotification = originalShowNotification ;
Main . messageTray . _hideNotification = originalHideNotification ;
Main . messageTray . _hideNotification = originalHideNotification ;
Main . messageTray . _updateShowingNotification = originalUpdateShowingNotification ;
Main . messageTray . _updateShowingNotification = originalUpdateShowingNotification ;
if ( ! ExtensionUtils . versionCheck ( [ '3.16' ] , Config . PACKAGE _VERSION ) ) {
Main . messageTray . _onNotificationExpanded = originalExpandMethod ;
Main . messageTray . _onNotificationExpanded = originalExpandMethod ;
}
}
}