From 957b3b69dc1117b45b0d3d406c9ec996ff3db3e4 Mon Sep 17 00:00:00 2001 From: Dan Winship <danw@gnome.org> Date: Wed, 21 Jul 2010 11:50:58 -0400 Subject: [PATCH] [lg] fix queue_relayout warnings https://bugzilla.gnome.org/show_bug.cgi?id=624940 --- js/ui/lookingGlass.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 5c350d1c9..19059da2a 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -365,17 +365,16 @@ function Inspector() { Inspector.prototype = { _init: function() { - let width = 150; - let primary = global.get_primary_monitor(); + let container = new Shell.GenericContainer({ width: 0, + height: 0 }); + container.connect('allocate', Lang.bind(this, this._allocate)); + Main.uiGroup.add_actor(container); + let eventHandler = new St.BoxLayout({ name: 'LookingGlassDialog', vertical: false, - y: primary.y + Math.floor(primary.height / 2), reactive: true }); this._eventHandler = eventHandler; - eventHandler.connect('notify::allocation', Lang.bind(this, function () { - eventHandler.x = primary.x + Math.floor((primary.width - eventHandler.width) / 2); - })); - Main.uiGroup.add_actor(eventHandler); + container.add_actor(eventHandler); this._displayText = new St.Label(); eventHandler.add(this._displayText, { expand: true }); @@ -398,6 +397,20 @@ Inspector.prototype = { this._pointerTarget = null; }, + _allocate: function(actor, box, flags) { + let primary = global.get_primary_monitor(); + + let [minWidth, minHeight, natWidth, natHeight] = + this._eventHandler.get_preferred_size(); + + let childBox = new Clutter.ActorBox(); + childBox.x1 = primary.x + Math.floor((primary.width - natWidth) / 2); + childBox.x2 = childBox.x1 + natWidth; + childBox.y1 = primary.y + Math.floor((primary.height - natHeight) / 2); + childBox.y2 = childBox.y1 + natHeight; + this._eventHandler.allocate(childBox, flags); + }, + _close: function() { Clutter.ungrab_pointer(this._eventHandler); Clutter.ungrab_keyboard(this._eventHandler);