[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
124
js/ui/chrome.js
124
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');
|
|
||||||
|
|
||||||
|
if (params.visibleInOverview)
|
||||||
|
this.actor.add_actor(actor);
|
||||||
|
else
|
||||||
this.nonOverviewActor.add_actor(actor);
|
this.nonOverviewActor.add_actor(actor);
|
||||||
|
|
||||||
if (shapeActor)
|
this._trackActor(actor, params.affectsInputRegion, params.affectsStruts);
|
||||||
this._trackActor(shapeActor, true, true);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// setVisibleInOverview:
|
// trackActor:
|
||||||
// @actor: an actor in the chrome layer
|
// @actor: a descendant of the chrome to begin tracking
|
||||||
// @visible: Overview visibility
|
// @params: parameters describing how to track @actor
|
||||||
//
|
//
|
||||||
// By default, actors in the chrome layer are automatically hidden
|
// Tells the chrome to track @actor, which must be a descendant
|
||||||
// when the Overview is shown. This can be used to override that
|
// of an actor added via addActor(). This can be used to extend the
|
||||||
// behavior
|
// struts or input region to cover specific children.
|
||||||
setVisibleInOverview: function(actor, visible) {
|
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');
|
||||||
|
|
||||||
if (visible)
|
params = Params.parse(params, { affectsStruts: true,
|
||||||
actor.reparent(this.actor);
|
affectsInputRegion: true });
|
||||||
else
|
this._trackActor(actor, params.affectsInputRegion, params.affectsStruts);
|
||||||
actor.reparent(this.nonOverviewActor);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// addInputRegionActor:
|
// untrackActor:
|
||||||
// @actor: an actor to add to the stage input region
|
// @actor: an actor previously tracked via trackActor()
|
||||||
//
|
//
|
||||||
// Adds @actor to the stage input region, as with addActor(), but
|
// Undoes the effect of trackActor()
|
||||||
// for actors that are already descendants of the chrome layer.
|
untrackActor: function(actor) {
|
||||||
addInputRegionActor: function(actor) {
|
this._untrackActor(actor);
|
||||||
if (!this._verifyAncestry(actor, this.actor))
|
|
||||||
throw new Error('actor is not a descendent of the chrome layer');
|
|
||||||
|
|
||||||
this._trackActor(actor, true, false);
|
|
||||||
},
|
|
||||||
|
|
||||||
// removeInputRegionActor:
|
|
||||||
// @actor: an actor previously added to the stage input region
|
|
||||||
//
|
|
||||||
// Undoes the effect of addInputRegionActor()
|
|
||||||
removeInputRegionActor: function(actor) {
|
|
||||||
this._untrackActor(actor, true, false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
actor = actor.get_parent();
|
|
||||||
if (actor != this.actor && actor != this.nonOverviewActor)
|
|
||||||
this._trackActor(actor, false, false);
|
|
||||||
|
|
||||||
if (inputRegion || strut)
|
|
||||||
this._queueUpdateRegions();
|
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)
|
|
||||||
actorData.inputRegion--;
|
|
||||||
if (strut)
|
|
||||||
actorData.strut--;
|
|
||||||
if (!inputRegion && !strut)
|
|
||||||
actorData.children--;
|
|
||||||
|
|
||||||
if (actorData.inputRegion <= 0 && actorData.strut <= 0 && actorData.children <= 0) {
|
|
||||||
this._trackedActors.splice(i, 1);
|
this._trackedActors.splice(i, 1);
|
||||||
actor.disconnect(actorData.visibleId);
|
actor.disconnect(actorData.visibleId);
|
||||||
actor.disconnect(actorData.allocationId);
|
actor.disconnect(actorData.allocationId);
|
||||||
actor.disconnect(actorData.parentSetId);
|
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();
|
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