From dd0f72169451fe4d296908e07ee3389a570c6aa3 Mon Sep 17 00:00:00 2001 From: Adel Gadllah Date: Tue, 4 Jan 2011 17:19:05 +0100 Subject: [PATCH] calendar: Use AlignConstraint to center the popup This fixes warnings like: (mutter:12238): Clutter-WARNING **: The actor 'calendarPopup' is currently inside an allocation cycle; calling clutter_actor_queue_relayout() is not recommended https://bugzilla.gnome.org/show_bug.cgi?id=637829 --- js/ui/panel.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index eb994d172..4439d3d4d 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -977,6 +977,9 @@ function CalendarPopup() { CalendarPopup.prototype = { _init: function() { let panelActor = Main.panel.actor; + let alignConstraint = new Clutter.AlignConstraint({ source: panelActor, + align_axis: Clutter.AlignAxis.X_AXIS, + factor: 0.5 }); this.actor = new St.Bin({ name: 'calendarPopup' }); @@ -988,7 +991,7 @@ CalendarPopup.prototype = { Main.chrome.addActor(this.actor, { visibleInOverview: true, affectsStruts: false }); this.actor.y = (panelActor.y + panelActor.height - this.actor.height); - this.calendar.actor.connect('notify::width', Lang.bind(this, this._centerPopup)); + this.actor.add_constraint(alignConstraint); }, show: function() { @@ -1001,7 +1004,6 @@ CalendarPopup.prototype = { // Reset the calendar to today's date this.calendar.setDate(new Date()); - this._centerPopup(); this.actor.lower(panelActor); this.actor.show(); Tweener.addTween(this.actor, @@ -1025,10 +1027,5 @@ CalendarPopup.prototype = { onComplete: function() { this.actor.hide(); }, onCompleteScope: this }); - }, - - _centerPopup: function() { - let panelActor = Main.panel.actor; - this.actor.x = Math.round(panelActor.x + (panelActor.width - this.actor.width) / 2); } };