From 8b2864ee702b633f2862d063a16b2d8afa4e6e83 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 24 Dec 2012 15:19:22 +0100 Subject: [PATCH] Main: move the stage hierarchy initialization to LayoutManager It is cleaner to concentrate all layout and chrome management in one place, instead of having it scattered around the codebase. https://bugzilla.gnome.org/show_bug.cgi?id=682429 --- js/ui/layout.js | 49 +++++++++++++++++++++++++++++++++++++++++++------ js/ui/main.js | 39 +++++++-------------------------------- js/ui/panel.js | 2 +- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/js/ui/layout.js b/js/ui/layout.js index d1c88347c..53ea4bdf0 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -18,6 +18,7 @@ const HOT_CORNER_ACTIVATION_TIMEOUT = 0.5; const STARTUP_ANIMATION_TIME = 0.2; const KEYBOARD_ANIMATION_TIME = 0.15; const PLYMOUTH_TRANSITION_TIME = 1; +const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff); const MonitorConstraint = new Lang.Class({ Name: 'MonitorConstraint', @@ -119,6 +120,42 @@ const LayoutManager = new Lang.Class({ this._trackedActors = []; + // Normally, the stage is always covered so Clutter doesn't need to clear + // it; however it becomes visible during the startup animation + // See the comment below for a longer explanation + global.stage.color = DEFAULT_BACKGROUND_COLOR; + + // Set up stage hierarchy to group all UI actors under one container. + this.uiGroup = new Shell.GenericContainer({ name: 'uiGroup' }); + this.uiGroup.connect('allocate', + function (actor, box, flags) { + let children = actor.get_children(); + for (let i = 0; i < children.length; i++) + children[i].allocate_preferred_size(flags); + }); + this.uiGroup.connect('get-preferred-width', + function(actor, forHeight, alloc) { + let width = global.stage.width; + [alloc.min_size, alloc.natural_size] = [width, width]; + }); + this.uiGroup.connect('get-preferred-height', + function(actor, forWidth, alloc) { + let height = global.stage.height; + [alloc.min_size, alloc.natural_size] = [height, height]; + }); + + global.window_group.reparent(this.uiGroup); + + // Now, you might wonder why we went through all the hoops to implement + // the GDM greeter inside an X11 compositor, to do this at the end... + // However, hiding this is necessary to avoid showing the background during + // the initial animation, before Gdm.LoginDialog covers everything + if (Main.sessionMode.isGreeter) + global.window_group.hide(); + + global.overlay_group.reparent(this.uiGroup); + global.stage.add_child(this.uiGroup); + this.screenShieldGroup = new St.Widget({ name: 'screenShieldGroup', visible: false, clip_to_allocation: true, @@ -253,7 +290,7 @@ const LayoutManager = new Lang.Class({ if (!haveTopLeftCorner) continue; - let corner = new HotCorner(); + let corner = new HotCorner(this); this._hotCorners.push(corner); corner.actor.set_position(cornerX, cornerY); this.addChrome(corner.actor); @@ -475,7 +512,7 @@ const LayoutManager = new Lang.Class({ // monitor (it will be hidden whenever a fullscreen window is visible, // and shown otherwise) addChrome: function(actor, params) { - Main.uiGroup.add_actor(actor); + this.uiGroup.add_actor(actor); this._trackActor(actor, params); }, @@ -526,7 +563,7 @@ const LayoutManager = new Lang.Class({ // // Removes @actor from the chrome removeChrome: function(actor) { - Main.uiGroup.remove_actor(actor); + this.uiGroup.remove_actor(actor); this._untrackActor(actor); }, @@ -545,7 +582,7 @@ const LayoutManager = new Lang.Class({ let actorData = Params.parse(params, defaultParams); actorData.actor = actor; - actorData.isToplevel = actor.get_parent() == Main.uiGroup; + actorData.isToplevel = actor.get_parent() == this.uiGroup; actorData.visibleId = actor.connect('notify::visible', Lang.bind(this, this._queueUpdateRegions)); actorData.allocationId = actor.connect('notify::allocation', @@ -581,7 +618,7 @@ const LayoutManager = new Lang.Class({ } else { let i = this._findActor(actor); let actorData = this._trackedActors[i]; - actorData.isToplevel = (newParent == Main.uiGroup); + actorData.isToplevel = (newParent == this.uiGroup); } }, @@ -781,7 +818,7 @@ const LayoutManager = new Lang.Class({ if (actorData.affectsInputRegion && actorData.actor.get_paint_visibility() && - !Main.uiGroup.get_skip_paint(actorData.actor)) + !this.uiGroup.get_skip_paint(actorData.actor)) rects.push(rect); if (!actorData.affectsStruts) diff --git a/js/ui/main.js b/js/ui/main.js index c7e65ee34..a5d35e3d5 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -38,7 +38,6 @@ const XdndHandler = imports.ui.xdndHandler; const Util = imports.misc.util; const OVERRIDES_SCHEMA = 'org.gnome.shell.overrides'; -const DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff); let componentManager = null; let panel = null; @@ -112,41 +111,17 @@ function start() { tracker.connect('startup-sequence-changed', _queueCheckWorkspaces); - // The stage is always covered so Clutter doesn't need to clear it; however - // the color is used as the default contents for the Mutter root background - // actor so set it anyways. - global.stage.color = DEFAULT_BACKGROUND_COLOR; - global.stage.no_clear_hint = true; - - _defaultCssStylesheet = global.datadir + '/theme/gnome-shell.css'; - loadTheme(); - - // Set up stage hierarchy to group all UI actors under one container. - uiGroup = new Shell.GenericContainer({ name: 'uiGroup' }); - uiGroup.connect('allocate', - function (actor, box, flags) { - let children = uiGroup.get_children(); - for (let i = 0; i < children.length; i++) - children[i].allocate_preferred_size(flags); - }); - uiGroup.connect('get-preferred-width', - function(actor, forHeight, alloc) { - let width = global.stage.width; - [alloc.min_size, alloc.natural_size] = [width, width]; - }); - uiGroup.connect('get-preferred-height', - function(actor, forWidth, alloc) { - let height = global.stage.height; - [alloc.min_size, alloc.natural_size] = [height, height]; - }); - global.window_group.reparent(uiGroup); - global.overlay_group.reparent(uiGroup); - global.stage.add_actor(uiGroup); + // Setup the stage hierarchy early + layoutManager = new Layout.LayoutManager(); + // For backward compatibility + uiGroup = layoutManager.uiGroup; let backgroundActor = global.window_group.background; background = backgroundActor.settings; - layoutManager = new Layout.LayoutManager(); + _defaultCssStylesheet = global.datadir + '/theme/gnome-shell.css'; + loadTheme(); + xdndHandler = new XdndHandler.XdndHandler(); ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager(); overview = new Overview.Overview(); diff --git a/js/ui/panel.js b/js/ui/panel.js index 0a0de0373..42818e898 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -644,7 +644,7 @@ const ActivitiesButton = new Lang.Class({ this.actor.label_actor = this._label; - this.hotCorner = new Layout.HotCorner(); + this.hotCorner = new Layout.HotCorner(Main.layoutManager); container.add_actor(this.hotCorner.actor); this.actor.connect('captured-event', Lang.bind(this, this._onCapturedEvent));