layout: make Chrome an implementation detail of LayoutManager
Make the Chrome object be a private member of LayoutManager, and add new LayoutManager methods to proxy to the old Chrome methods. https://bugzilla.gnome.org/show_bug.cgi?id=655813
This commit is contained in:
parent
99149f9c41
commit
c1acf992fa
126
js/ui/layout.js
126
js/ui/layout.js
@ -27,15 +27,18 @@ LayoutManager.prototype = {
|
|||||||
this.primaryIndex = -1;
|
this.primaryIndex = -1;
|
||||||
this._hotCorners = [];
|
this._hotCorners = [];
|
||||||
|
|
||||||
|
global.screen.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
|
||||||
this._updateMonitors();
|
this._updateMonitors();
|
||||||
|
|
||||||
|
this._chrome = new Chrome(this);
|
||||||
|
this._updateHotCorners();
|
||||||
},
|
},
|
||||||
|
|
||||||
// This is called by Main after everything else is constructed;
|
// This is called by Main after everything else is constructed;
|
||||||
// _updateHotCorners needs access to Main.panel, which didn't exist
|
// Chrome.init() needs access to Main.overview, which didn't exist
|
||||||
// yet when the LayoutManager was constructed.
|
// yet when the LayoutManager was constructed.
|
||||||
init: function() {
|
init: function() {
|
||||||
global.screen.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
|
this._chrome.init();
|
||||||
this._updateHotCorners();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateMonitors: function() {
|
_updateMonitors: function() {
|
||||||
@ -114,7 +117,7 @@ LayoutManager.prototype = {
|
|||||||
let corner = new HotCorner();
|
let corner = new HotCorner();
|
||||||
this._hotCorners.push(corner);
|
this._hotCorners.push(corner);
|
||||||
corner.actor.set_position(cornerX, cornerY);
|
corner.actor.set_position(cornerX, cornerY);
|
||||||
Main.chrome.addActor(corner.actor);
|
this._chrome.addActor(corner.actor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -159,6 +162,60 @@ LayoutManager.prototype = {
|
|||||||
|
|
||||||
get focusMonitor() {
|
get focusMonitor() {
|
||||||
return this.monitors[this.focusIndex];
|
return this.monitors[this.focusIndex];
|
||||||
|
},
|
||||||
|
|
||||||
|
// addChrome:
|
||||||
|
// @actor: an actor to add to the chrome layer
|
||||||
|
// @params: (optional) additional params
|
||||||
|
//
|
||||||
|
// Adds @actor to the chrome layer and (unless %affectsInputRegion
|
||||||
|
// in @params is %false) extends the input region to include it.
|
||||||
|
// Changes in @actor's size, position, and visibility will
|
||||||
|
// automatically result in appropriate changes to the input
|
||||||
|
// region.
|
||||||
|
//
|
||||||
|
// If %affectsStruts in @params is %true (and @actor is along a
|
||||||
|
// screen edge), then @actor's size and position will also affect
|
||||||
|
// the window manager struts. Changes to @actor's visibility will
|
||||||
|
// NOT affect whether or not the strut is present, however.
|
||||||
|
//
|
||||||
|
// If %visibleInFullscreen in @params is %true, the actor will be
|
||||||
|
// visible even when a fullscreen window should be covering it.
|
||||||
|
addChrome: function(actor, params) {
|
||||||
|
this._chrome.addActor(actor, params);
|
||||||
|
},
|
||||||
|
|
||||||
|
// trackChrome:
|
||||||
|
// @actor: a descendant of the chrome to begin tracking
|
||||||
|
// @params: parameters describing how to track @actor
|
||||||
|
//
|
||||||
|
// Tells the chrome to track @actor, which must be a descendant
|
||||||
|
// of an actor added via addChrome(). This can be used to extend the
|
||||||
|
// struts or input region to cover specific children.
|
||||||
|
//
|
||||||
|
// @params can have any of the same values as in addChrome(),
|
||||||
|
// though some possibilities don't make sense (eg, trying to have
|
||||||
|
// a %visibleInFullscreen child of a non-%visibleInFullscreen
|
||||||
|
// parent). By default, @actor has the same params as its chrome
|
||||||
|
// ancestor.
|
||||||
|
trackChrome: function(actor, params) {
|
||||||
|
this._chrome.trackActor(actor, params);
|
||||||
|
},
|
||||||
|
|
||||||
|
// untrackChrome:
|
||||||
|
// @actor: an actor previously tracked via trackChrome()
|
||||||
|
//
|
||||||
|
// Undoes the effect of trackChrome()
|
||||||
|
untrackChrome: function(actor) {
|
||||||
|
this._chrome.untrackActor(actor);
|
||||||
|
},
|
||||||
|
|
||||||
|
// removeChrome:
|
||||||
|
// @actor: a child of the chrome layer
|
||||||
|
//
|
||||||
|
// Removes @actor from the chrome layer
|
||||||
|
removeChrome: function(actor) {
|
||||||
|
this._chrome.removeActor(actor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(LayoutManager.prototype);
|
Signals.addSignalMethods(LayoutManager.prototype);
|
||||||
@ -337,11 +394,13 @@ const defaultParams = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function Chrome() {
|
function Chrome() {
|
||||||
this._init();
|
this._init.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
Chrome.prototype = {
|
Chrome.prototype = {
|
||||||
_init: function() {
|
_init: function(layoutManager) {
|
||||||
|
this._layoutManager = layoutManager;
|
||||||
|
|
||||||
// The group itself has zero size so it doesn't interfere with DND
|
// The group itself has zero size so it doesn't interfere with DND
|
||||||
this.actor = new Shell.GenericContainer({ width: 0, height: 0 });
|
this.actor = new Shell.GenericContainer({ width: 0, height: 0 });
|
||||||
Main.uiGroup.add_actor(this.actor);
|
Main.uiGroup.add_actor(this.actor);
|
||||||
@ -352,7 +411,7 @@ Chrome.prototype = {
|
|||||||
|
|
||||||
this._trackedActors = [];
|
this._trackedActors = [];
|
||||||
|
|
||||||
Main.layoutManager.connect('monitors-changed',
|
this._layoutManager.connect('monitors-changed',
|
||||||
Lang.bind(this, this._relayout));
|
Lang.bind(this, this._relayout));
|
||||||
global.screen.connect('restacked',
|
global.screen.connect('restacked',
|
||||||
Lang.bind(this, this._windowsRestacked));
|
Lang.bind(this, this._windowsRestacked));
|
||||||
@ -361,11 +420,6 @@ Chrome.prototype = {
|
|||||||
global.screen.connect('notify::n-workspaces',
|
global.screen.connect('notify::n-workspaces',
|
||||||
Lang.bind(this, this._queueUpdateRegions));
|
Lang.bind(this, this._queueUpdateRegions));
|
||||||
|
|
||||||
Main.overview.connect('showing',
|
|
||||||
Lang.bind(this, this._overviewShowing));
|
|
||||||
Main.overview.connect('hidden',
|
|
||||||
Lang.bind(this, this._overviewHidden));
|
|
||||||
|
|
||||||
this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
|
this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
|
||||||
this._screenSaverProxy.connect('ActiveChanged', Lang.bind(this, this._onScreenSaverActiveChanged));
|
this._screenSaverProxy.connect('ActiveChanged', Lang.bind(this, this._onScreenSaverActiveChanged));
|
||||||
this._screenSaverProxy.GetActiveRemote(Lang.bind(this,
|
this._screenSaverProxy.GetActiveRemote(Lang.bind(this,
|
||||||
@ -377,45 +431,24 @@ Chrome.prototype = {
|
|||||||
this._relayout();
|
this._relayout();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
Main.overview.connect('showing',
|
||||||
|
Lang.bind(this, this._overviewShowing));
|
||||||
|
Main.overview.connect('hidden',
|
||||||
|
Lang.bind(this, this._overviewHidden));
|
||||||
|
},
|
||||||
|
|
||||||
_allocated: function(actor, box, flags) {
|
_allocated: function(actor, box, flags) {
|
||||||
let children = this.actor.get_children();
|
let children = this.actor.get_children();
|
||||||
for (let i = 0; i < children.length; i++)
|
for (let i = 0; i < children.length; i++)
|
||||||
children[i].allocate_preferred_size(flags);
|
children[i].allocate_preferred_size(flags);
|
||||||
},
|
},
|
||||||
|
|
||||||
// addActor:
|
|
||||||
// @actor: an actor to add to the chrome layer
|
|
||||||
// @params: (optional) additional params
|
|
||||||
//
|
|
||||||
// Adds @actor to the chrome layer and (unless %affectsInputRegion
|
|
||||||
// is %false) extends the input region to include it. Changes in
|
|
||||||
// @actor's size, position, and visibility will automatically
|
|
||||||
// result in appropriate changes to the input region.
|
|
||||||
//
|
|
||||||
// If %affectsStruts is %true (and @actor is along a screen edge),
|
|
||||||
// then @actor's size and position will also affect the window
|
|
||||||
// manager struts. Changes to @actor's visibility will NOT affect
|
|
||||||
// whether or not the strut is present, however.
|
|
||||||
//
|
|
||||||
// If %visibleInFullscreen is %true, the actor will be visible
|
|
||||||
// even when a fullscreen window should be covering it.
|
|
||||||
addActor: function(actor, params) {
|
addActor: function(actor, params) {
|
||||||
this.actor.add_actor(actor);
|
this.actor.add_actor(actor);
|
||||||
this._trackActor(actor, params);
|
this._trackActor(actor, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
// trackActor:
|
|
||||||
// @actor: a descendant of the chrome to begin tracking
|
|
||||||
// @params: parameters describing how to track @actor
|
|
||||||
//
|
|
||||||
// Tells the chrome to track @actor, which must be a descendant
|
|
||||||
// of an actor added via addActor(). This can be used to extend the
|
|
||||||
// struts or input region to cover specific children.
|
|
||||||
//
|
|
||||||
// @params can have any of the same values as in addActor(), though
|
|
||||||
// some possibilities don't make sense (eg, trying to have a
|
|
||||||
// %visibleInFullscreen child of a non-%visibleInFullscreen parent).
|
|
||||||
// By default, @actor has the same params as its chrome ancestor.
|
|
||||||
trackActor: function(actor, params) {
|
trackActor: function(actor, params) {
|
||||||
let ancestor = actor.get_parent();
|
let ancestor = actor.get_parent();
|
||||||
let index = this._findActor(ancestor);
|
let index = this._findActor(ancestor);
|
||||||
@ -439,18 +472,10 @@ Chrome.prototype = {
|
|||||||
this._trackActor(actor, params);
|
this._trackActor(actor, params);
|
||||||
},
|
},
|
||||||
|
|
||||||
// untrackActor:
|
|
||||||
// @actor: an actor previously tracked via trackActor()
|
|
||||||
//
|
|
||||||
// Undoes the effect of trackActor()
|
|
||||||
untrackActor: function(actor) {
|
untrackActor: function(actor) {
|
||||||
this._untrackActor(actor);
|
this._untrackActor(actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
// removeActor:
|
|
||||||
// @actor: a child of the chrome layer
|
|
||||||
//
|
|
||||||
// Removes @actor from the chrome layer
|
|
||||||
removeActor: function(actor) {
|
removeActor: function(actor) {
|
||||||
this.actor.remove_actor(actor);
|
this.actor.remove_actor(actor);
|
||||||
this._untrackActor(actor);
|
this._untrackActor(actor);
|
||||||
@ -528,8 +553,8 @@ Chrome.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_relayout: function() {
|
_relayout: function() {
|
||||||
this._monitors = Main.layoutManager.monitors;
|
this._monitors = this._layoutManager.monitors;
|
||||||
this._primaryMonitor = Main.layoutManager.primaryMonitor;
|
this._primaryMonitor = this._layoutManager.primaryMonitor;
|
||||||
|
|
||||||
this._updateFullscreen();
|
this._updateFullscreen();
|
||||||
this._updateVisibility();
|
this._updateVisibility();
|
||||||
@ -757,4 +782,3 @@ Chrome.prototype = {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Signals.addSignalMethods(Chrome.prototype);
|
|
||||||
|
@ -752,7 +752,7 @@ LookingGlass.prototype = {
|
|||||||
|
|
||||||
// we add it to the chrome because we want it to appear to slide
|
// we add it to the chrome because we want it to appear to slide
|
||||||
// out from underneath the panel
|
// out from underneath the panel
|
||||||
Main.chrome.addActor(this.actor);
|
Main.layoutManager.addChrome(this.actor);
|
||||||
|
|
||||||
this._objInspector = new ObjInspector();
|
this._objInspector = new ObjInspector();
|
||||||
Main.uiGroup.add_actor(this._objInspector.actor);
|
Main.uiGroup.add_actor(this._objInspector.actor);
|
||||||
|
@ -42,7 +42,6 @@ DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff);
|
|||||||
|
|
||||||
let automountManager = null;
|
let automountManager = null;
|
||||||
let autorunManager = null;
|
let autorunManager = null;
|
||||||
let chrome = null;
|
|
||||||
let panel = null;
|
let panel = null;
|
||||||
let hotCorners = [];
|
let hotCorners = [];
|
||||||
let placesManager = null;
|
let placesManager = null;
|
||||||
@ -136,7 +135,6 @@ function start() {
|
|||||||
xdndHandler = new XdndHandler.XdndHandler();
|
xdndHandler = new XdndHandler.XdndHandler();
|
||||||
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
|
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
|
||||||
overview = new Overview.Overview();
|
overview = new Overview.Overview();
|
||||||
chrome = new Layout.Chrome();
|
|
||||||
magnifier = new Magnifier.Magnifier();
|
magnifier = new Magnifier.Magnifier();
|
||||||
statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
|
statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
|
||||||
panel = new Panel.Panel();
|
panel = new Panel.Panel();
|
||||||
|
@ -1279,7 +1279,7 @@ MessageTray.prototype = {
|
|||||||
track_hover: true });
|
track_hover: true });
|
||||||
this._summaryBoxPointer.actor.style_class = 'summary-boxpointer';
|
this._summaryBoxPointer.actor.style_class = 'summary-boxpointer';
|
||||||
this._summaryBoxPointer.actor.hide();
|
this._summaryBoxPointer.actor.hide();
|
||||||
Main.chrome.addActor(this._summaryBoxPointer.actor, { visibleInFullscreen: true });
|
Main.layoutManager.addChrome(this._summaryBoxPointer.actor, { visibleInFullscreen: true });
|
||||||
|
|
||||||
this._summaryBoxPointerItem = null;
|
this._summaryBoxPointerItem = null;
|
||||||
this._summaryBoxPointerContentUpdatedId = 0;
|
this._summaryBoxPointerContentUpdatedId = 0;
|
||||||
@ -1329,8 +1329,8 @@ MessageTray.prototype = {
|
|||||||
this._notificationRemoved = false;
|
this._notificationRemoved = false;
|
||||||
this._reNotifyAfterHideNotification = null;
|
this._reNotifyAfterHideNotification = null;
|
||||||
|
|
||||||
Main.chrome.addActor(this.actor, { visibleInFullscreen: true });
|
Main.layoutManager.addChrome(this.actor, { visibleInFullscreen: true });
|
||||||
Main.chrome.trackActor(this._notificationBin);
|
Main.layoutManager.trackChrome(this._notificationBin);
|
||||||
|
|
||||||
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
|
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._setSizePosition));
|
||||||
|
|
||||||
|
@ -871,7 +871,7 @@ Panel.prototype = {
|
|||||||
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
|
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
|
||||||
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
|
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
|
||||||
|
|
||||||
Main.chrome.addActor(this.actor, { affectsStruts: true });
|
Main.layoutManager.addChrome(this.actor, { affectsStruts: true });
|
||||||
|
|
||||||
Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'start-here',
|
Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'start-here',
|
||||||
{ sortGroup: CtrlAltTab.SortGroup.TOP });
|
{ sortGroup: CtrlAltTab.SortGroup.TOP });
|
||||||
|
@ -27,7 +27,7 @@ Button.prototype = {
|
|||||||
this.menu.actor.add_style_class_name('panel-menu');
|
this.menu.actor.add_style_class_name('panel-menu');
|
||||||
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
|
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
|
||||||
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
|
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
|
||||||
Main.chrome.addActor(this.menu.actor);
|
Main.layoutManager.addChrome(this.menu.actor);
|
||||||
this.menu.actor.hide();
|
this.menu.actor.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user