[Chrome] clean up APIs and remove workarounds
https://bugzilla.gnome.org/show_bug.cgi?id=597044
This commit is contained in:
parent
e9787c0f1e
commit
b0cb8fb85a
138
js/ui/chrome.js
138
js/ui/chrome.js
@ -7,6 +7,7 @@ const Meta = imports.gi.Meta;
|
|||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
|
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
|
const Params = imports.misc.params;
|
||||||
|
|
||||||
// This manages the shell "chrome"; the UI that's visible in the
|
// This manages the shell "chrome"; the UI that's visible in the
|
||||||
// normal mode (ie, outside the Overview), that surrounds the main
|
// normal mode (ie, outside the Overview), that surrounds the main
|
||||||
@ -54,7 +55,7 @@ Chrome.prototype = {
|
|||||||
|
|
||||||
// addActor:
|
// addActor:
|
||||||
// @actor: an actor to add to the chrome layer
|
// @actor: an actor to add to the chrome layer
|
||||||
// @shapeActor: optional "shape actor".
|
// @params: (optional) additional params
|
||||||
//
|
//
|
||||||
// Adds @actor to the chrome layer and extends the input region
|
// Adds @actor to the chrome layer and extends the input region
|
||||||
// and window manager struts to include it. (Window manager struts
|
// and window manager struts to include it. (Window manager struts
|
||||||
@ -64,59 +65,45 @@ Chrome.prototype = {
|
|||||||
// in its visibility will affect the input region, but NOT the
|
// in its visibility will affect the input region, but NOT the
|
||||||
// struts.
|
// struts.
|
||||||
//
|
//
|
||||||
// If @shapeActor is provided, it will be used instead of @actor
|
// If %visibleInOverview is %true in @params, @actor will remain
|
||||||
// for the input region/strut shape. (This lets you have things like
|
// visible when the overview is brought up. Otherwise it will
|
||||||
// drop shadows in @actor that don't affect the struts.) It must
|
// automatically be hidden. If %affectsStruts or %affectsInputRegion
|
||||||
// be a child of @actor. Alternatively, you can pass %null for
|
// is %false, the actor will not have the indicated effect.
|
||||||
// @shapeActor to indicate that @actor should not affect the input
|
addActor: function(actor, params) {
|
||||||
// region or struts at all.
|
params = Params.parse(params, { visibleInOverview: false,
|
||||||
addActor: function(actor, shapeActor) {
|
affectsStruts: true,
|
||||||
if (shapeActor === undefined)
|
affectsInputRegion: true });
|
||||||
shapeActor = actor;
|
|
||||||
else if (shapeActor && !this._verifyAncestry(shapeActor, actor))
|
|
||||||
throw new Error('shapeActor is not a descendent of actor');
|
|
||||||
|
|
||||||
this.nonOverviewActor.add_actor(actor);
|
if (params.visibleInOverview)
|
||||||
|
this.actor.add_actor(actor);
|
||||||
if (shapeActor)
|
|
||||||
this._trackActor(shapeActor, true, true);
|
|
||||||
},
|
|
||||||
|
|
||||||
// setVisibleInOverview:
|
|
||||||
// @actor: an actor in the chrome layer
|
|
||||||
// @visible: Overview visibility
|
|
||||||
//
|
|
||||||
// By default, actors in the chrome layer are automatically hidden
|
|
||||||
// when the Overview is shown. This can be used to override that
|
|
||||||
// behavior
|
|
||||||
setVisibleInOverview: function(actor, visible) {
|
|
||||||
if (!this._verifyAncestry(actor, this.actor))
|
|
||||||
throw new Error('actor is not a descendent of the chrome layer');
|
|
||||||
|
|
||||||
if (visible)
|
|
||||||
actor.reparent(this.actor);
|
|
||||||
else
|
else
|
||||||
actor.reparent(this.nonOverviewActor);
|
this.nonOverviewActor.add_actor(actor);
|
||||||
|
|
||||||
|
this._trackActor(actor, params.affectsInputRegion, params.affectsStruts);
|
||||||
},
|
},
|
||||||
|
|
||||||
// addInputRegionActor:
|
// trackActor:
|
||||||
// @actor: an actor to add to the stage input region
|
// @actor: a descendant of the chrome to begin tracking
|
||||||
|
// @params: parameters describing how to track @actor
|
||||||
//
|
//
|
||||||
// Adds @actor to the stage input region, as with addActor(), but
|
// Tells the chrome to track @actor, which must be a descendant
|
||||||
// for actors that are already descendants of the chrome layer.
|
// of an actor added via addActor(). This can be used to extend the
|
||||||
addInputRegionActor: function(actor) {
|
// struts or input region to cover specific children.
|
||||||
|
trackActor: function(actor, params) {
|
||||||
if (!this._verifyAncestry(actor, this.actor))
|
if (!this._verifyAncestry(actor, this.actor))
|
||||||
throw new Error('actor is not a descendent of the chrome layer');
|
throw new Error('actor is not a descendent of the chrome layer');
|
||||||
|
|
||||||
this._trackActor(actor, true, false);
|
params = Params.parse(params, { affectsStruts: true,
|
||||||
|
affectsInputRegion: true });
|
||||||
|
this._trackActor(actor, params.affectsInputRegion, params.affectsStruts);
|
||||||
},
|
},
|
||||||
|
|
||||||
// removeInputRegionActor:
|
// untrackActor:
|
||||||
// @actor: an actor previously added to the stage input region
|
// @actor: an actor previously tracked via trackActor()
|
||||||
//
|
//
|
||||||
// Undoes the effect of addInputRegionActor()
|
// Undoes the effect of trackActor()
|
||||||
removeInputRegionActor: function(actor) {
|
untrackActor: function(actor) {
|
||||||
this._untrackActor(actor, true, false);
|
this._untrackActor(actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
// removeActor:
|
// removeActor:
|
||||||
@ -128,7 +115,7 @@ Chrome.prototype = {
|
|||||||
this.nonOverviewActor.remove_actor(actor);
|
this.nonOverviewActor.remove_actor(actor);
|
||||||
else
|
else
|
||||||
this.actor.remove_actor(actor);
|
this.actor.remove_actor(actor);
|
||||||
this._untrackActor(actor, true, true);
|
this._untrackActor(actor);
|
||||||
},
|
},
|
||||||
|
|
||||||
_findActor: function(actor) {
|
_findActor: function(actor) {
|
||||||
@ -142,23 +129,13 @@ Chrome.prototype = {
|
|||||||
|
|
||||||
_trackActor: function(actor, inputRegion, strut) {
|
_trackActor: function(actor, inputRegion, strut) {
|
||||||
let actorData;
|
let actorData;
|
||||||
let i = this._findActor(actor);
|
|
||||||
|
|
||||||
if (i != -1) {
|
if (this._findActor(actor) != -1)
|
||||||
actorData = this._trackedActors[i];
|
throw new Error('trying to re-track existing chrome actor');
|
||||||
if (inputRegion)
|
|
||||||
actorData.inputRegion++;
|
|
||||||
if (strut)
|
|
||||||
actorData.strut++;
|
|
||||||
if (!inputRegion && !strut)
|
|
||||||
actorData.children++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
actorData = { actor: actor,
|
actorData = { actor: actor,
|
||||||
inputRegion: inputRegion ? 1 : 0,
|
inputRegion: inputRegion,
|
||||||
strut: strut ? 1 : 0,
|
strut: strut };
|
||||||
children: 0 };
|
|
||||||
|
|
||||||
actorData.visibleId = actor.connect('notify::visible',
|
actorData.visibleId = actor.connect('notify::visible',
|
||||||
Lang.bind(this, this._queueUpdateRegions));
|
Lang.bind(this, this._queueUpdateRegions));
|
||||||
@ -166,54 +143,31 @@ Chrome.prototype = {
|
|||||||
Lang.bind(this, this._queueUpdateRegions));
|
Lang.bind(this, this._queueUpdateRegions));
|
||||||
actorData.parentSetId = actor.connect('parent-set',
|
actorData.parentSetId = actor.connect('parent-set',
|
||||||
Lang.bind(this, this._actorReparented));
|
Lang.bind(this, this._actorReparented));
|
||||||
|
// Note that destroying actor will unset its parent, so we don't
|
||||||
|
// need to connect to 'destroy' too.
|
||||||
|
|
||||||
this._trackedActors.push(actorData);
|
this._trackedActors.push(actorData);
|
||||||
|
this._queueUpdateRegions();
|
||||||
actor = actor.get_parent();
|
|
||||||
if (actor != this.actor && actor != this.nonOverviewActor)
|
|
||||||
this._trackActor(actor, false, false);
|
|
||||||
|
|
||||||
if (inputRegion || strut)
|
|
||||||
this._queueUpdateRegions();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_untrackActor: function(actor, inputRegion, strut) {
|
_untrackActor: function(actor) {
|
||||||
let i = this._findActor(actor);
|
let i = this._findActor(actor);
|
||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
return;
|
return;
|
||||||
let actorData = this._trackedActors[i];
|
let actorData = this._trackedActors[i];
|
||||||
|
|
||||||
if (inputRegion)
|
this._trackedActors.splice(i, 1);
|
||||||
actorData.inputRegion--;
|
actor.disconnect(actorData.visibleId);
|
||||||
if (strut)
|
actor.disconnect(actorData.allocationId);
|
||||||
actorData.strut--;
|
actor.disconnect(actorData.parentSetId);
|
||||||
if (!inputRegion && !strut)
|
|
||||||
actorData.children--;
|
|
||||||
|
|
||||||
if (actorData.inputRegion <= 0 && actorData.strut <= 0 && actorData.children <= 0) {
|
this._queueUpdateRegions();
|
||||||
this._trackedActors.splice(i, 1);
|
|
||||||
actor.disconnect(actorData.visibleId);
|
|
||||||
actor.disconnect(actorData.allocationId);
|
|
||||||
actor.disconnect(actorData.parentSetId);
|
|
||||||
|
|
||||||
actor = actor.get_parent();
|
|
||||||
if (actor && actor != this.actor && actor != this.nonOverviewActor)
|
|
||||||
this._untrackActor(actor, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inputRegion || strut)
|
|
||||||
this._queueUpdateRegions();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_actorReparented: function(actor, oldParent) {
|
_actorReparented: function(actor, oldParent) {
|
||||||
if (this._verifyAncestry(actor, this.actor)) {
|
if (!this._verifyAncestry(actor, this.actor))
|
||||||
let newParent = actor.get_parent();
|
this._untrackActor(actor);
|
||||||
if (newParent != this.actor && newParent != this.nonOverviewActor)
|
|
||||||
this._trackActor(newParent, false, false);
|
|
||||||
}
|
|
||||||
if (oldParent != this.actor && oldParent != this.nonOverviewActor)
|
|
||||||
this._untrackActor(oldParent, false, false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_overviewShowing: function() {
|
_overviewShowing: function() {
|
||||||
|
@ -420,8 +420,7 @@ Panel.prototype = {
|
|||||||
this.button.actor.active = false;
|
this.button.actor.active = false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Main.chrome.addActor(this.actor);
|
Main.chrome.addActor(this.actor, { visibleInOverview: true });
|
||||||
Main.chrome.setVisibleInOverview(this.actor, true);
|
|
||||||
|
|
||||||
// Start the clock
|
// Start the clock
|
||||||
this._updateClock();
|
this._updateClock();
|
||||||
@ -558,12 +557,8 @@ CalendarPopup.prototype = {
|
|||||||
this.calendar = new Calendar.Calendar();
|
this.calendar = new Calendar.Calendar();
|
||||||
this.actor.add(this.calendar.actor);
|
this.actor.add(this.calendar.actor);
|
||||||
|
|
||||||
// Directly adding the actor to Main.chrome.actor is a hack to
|
Main.chrome.addActor(this.actor, { visibleInOverview: true,
|
||||||
// work around the fact that there is no way to add an actor that
|
affectsStruts: false });
|
||||||
// affects the input region but not the shape.
|
|
||||||
// See: https://bugzilla.gnome.org/show_bug.cgi?id=597044
|
|
||||||
Main.chrome.actor.add_actor(this.actor);
|
|
||||||
Main.chrome.addInputRegionActor(this.actor);
|
|
||||||
this.actor.y = (panelActor.y + panelActor.height - this.actor.height);
|
this.actor.y = (panelActor.y + panelActor.height - this.actor.height);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ WidgetBox.prototype = {
|
|||||||
onCompleteScope: this });
|
onCompleteScope: this });
|
||||||
this.state = this._widget.state = Widget.STATE_POPPING_OUT;
|
this.state = this._widget.state = Widget.STATE_POPPING_OUT;
|
||||||
|
|
||||||
Main.chrome.addInputRegionActor(this._hbox);
|
Main.chrome.trackActor(this._hbox, { affectsStruts: false });
|
||||||
},
|
},
|
||||||
|
|
||||||
_popOutComplete: function() {
|
_popOutComplete: function() {
|
||||||
@ -370,7 +370,7 @@ WidgetBox.prototype = {
|
|||||||
this._egroup.hide();
|
this._egroup.hide();
|
||||||
this._ebox.x = 0;
|
this._ebox.x = 0;
|
||||||
|
|
||||||
Main.chrome.removeInputRegionActor(this._hbox);
|
Main.chrome.untrackActor(this._hbox);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user