[Chrome] add "visibleInFullscreen" property

Chrome elements with this flag set will be visible even when a
fullscreen window is present.

https://bugzilla.gnome.org/show_bug.cgi?id=608667
This commit is contained in:
Dan Winship 2010-04-28 15:41:05 -04:00
parent 31914ab23b
commit dd0882aa8b

View File

@ -5,6 +5,7 @@ const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta; const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Signals = imports.signals;
const Main = imports.ui.main; const Main = imports.ui.main;
const Params = imports.misc.params; const Params = imports.misc.params;
@ -13,8 +14,15 @@ const Params = imports.misc.params;
// normal mode (ie, outside the Overview), that surrounds the main // normal mode (ie, outside the Overview), that surrounds the main
// workspace content. // workspace content.
const Visibility = {
FULL: 1,
FULLSCREEN: 2,
OVERVIEW: 3
};
const defaultParams = { const defaultParams = {
visibleInOverview: false, visibleInOverview: false,
visibleInFullscreen: false,
affectsStruts: true, affectsStruts: true,
affectsInputRegion: true affectsInputRegion: true
}; };
@ -30,7 +38,9 @@ Chrome.prototype = {
global.stage.add_actor(this.actor); global.stage.add_actor(this.actor);
this.actor.connect('allocate', Lang.bind(this, this._allocated)); this.actor.connect('allocate', Lang.bind(this, this._allocated));
this._obscuredByFullscreen = false; this._inFullscreen = false;
this._inOverview = false;
this.visibility = Visibility.FULL;
this._trackedActors = []; this._trackedActors = [];
@ -78,8 +88,12 @@ Chrome.prototype = {
// //
// If %visibleInOverview is %true in @params, @actor will remain // If %visibleInOverview is %true in @params, @actor will remain
// visible when the overview is brought up. Otherwise it will // visible when the overview is brought up. Otherwise it will
// automatically be hidden. If %affectsStruts or %affectsInputRegion // automatically be hidden. Likewise, if %visibleInFullscreen is
// is %false, the actor will not have the indicated effect. // %true, the actor will be visible even when a fullscreen window
// should be covering it.
//
// If %affectsStruts or %affectsInputRegion is %false, the actor
// will not have the indicated effect.
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);
@ -185,20 +199,40 @@ Chrome.prototype = {
this._untrackActor(actor); this._untrackActor(actor);
}, },
_overviewShowing: function() { _updateVisibility: function() {
this.actor.show();
for (let i = 0; i < this._trackedActors.length; i++) { for (let i = 0; i < this._trackedActors.length; i++) {
if (!this._trackedActors[i].visibleInOverview) let actorData = this._trackedActors[i];
this.actor.set_skip_paint(this._trackedActors[i].actor, true); if (this._inOverview && !actorData.visibleInOverview)
this.actor.set_skip_paint(actorData.actor, true);
else if (this._inFullscreen && !actorData.visibleInFullscreen)
this.actor.set_skip_paint(actorData.actor, true);
else
this.actor.set_skip_paint(actorData.actor, false);
} }
let newVisibility;
if (this._inOverview)
newVisibility = Visibility.OVERVIEW;
else if (this._inFullscreen)
newVisibility = Visibility.FULLSCREEN;
else
newVisibility = Visibility.FULL;
if (newVisibility != this.visibility) {
this.visibility = newVisibility;
this.emit('visibility-changed', this.visibility);
}
},
_overviewShowing: function() {
this._inOverview = true;
this._updateVisibility();
this._queueUpdateRegions(); this._queueUpdateRegions();
}, },
_overviewHidden: function() { _overviewHidden: function() {
if (this._obscuredByFullscreen) this._inOverview = false;
this.actor.hide(); this._updateVisibility();
for (let i = 0; i < this._trackedActors.length; i++)
this.actor.set_skip_paint(this._trackedActors[i].actor, false);
this._queueUpdateRegions(); this._queueUpdateRegions();
}, },
@ -224,7 +258,8 @@ Chrome.prototype = {
// @windows is sorted bottom to top. // @windows is sorted bottom to top.
this._obscuredByFullscreen = false; let wasInFullscreen = this._inFullscreen;
this._inFullscreen = false;
for (let i = windows.length - 1; i > -1; i--) { for (let i = windows.length - 1; i > -1; i--) {
let layer = windows[i].get_meta_window().get_layer(); let layer = windows[i].get_meta_window().get_layer();
@ -239,7 +274,7 @@ Chrome.prototype = {
if (layer == Meta.StackLayer.FULLSCREEN) { if (layer == Meta.StackLayer.FULLSCREEN) {
if (Math.max(windows[i].x, 0) >= primary.x && Math.max(windows[i].x, 0) < primary.x + primary.width && if (Math.max(windows[i].x, 0) >= primary.x && Math.max(windows[i].x, 0) < primary.x + primary.width &&
Math.max(windows[i].y, 0) >= primary.y && Math.max(windows[i].y, 0) < primary.y + primary.height) { Math.max(windows[i].y, 0) >= primary.y && Math.max(windows[i].y, 0) < primary.y + primary.height) {
this._obscuredByFullscreen = true; this._inFullscreen = true;
break; break;
} }
} }
@ -248,16 +283,15 @@ Chrome.prototype = {
windows[i].x + windows[i].width >= primary.x + primary.width && windows[i].x + windows[i].width >= primary.x + primary.width &&
windows[i].y <= primary.y && windows[i].y <= primary.y &&
windows[i].y + windows[i].height >= primary.y + primary.height) { windows[i].y + windows[i].height >= primary.y + primary.height) {
this._obscuredByFullscreen = true; this._inFullscreen = true;
break; break;
} }
} else } else
break; break;
} }
let shouldBeVisible = !this._obscuredByFullscreen || Main.overview.visible; if (this._inFullscreen != wasInFullscreen) {
if (this.actor.visible != shouldBeVisible) { this._updateVisibility();
this.actor.visible = shouldBeVisible;
this._queueUpdateRegions(); this._queueUpdateRegions();
} }
}, },
@ -337,3 +371,4 @@ Chrome.prototype = {
return false; return false;
} }
}; };
Signals.addSignalMethods(Chrome.prototype);