Reorganize overlay hiding/showing code

Rather than having main.js manage this, put it into overlay.js, and
have the overlay object emit signals that other code can watch to do
things when the overlay is showing/shown/hiding/hidden.
This commit is contained in:
Dan Winship 2009-05-07 09:47:48 -04:00
parent 17fb280884
commit 062e1aa78b
5 changed files with 29 additions and 45 deletions

View File

@ -3,6 +3,7 @@
const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk;
const Gio = imports.gi.Gio;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
@ -19,7 +20,6 @@ DEFAULT_BACKGROUND_COLOR.from_pixel(0x2266bbff);
let panel = null;
let overlay = null;
let overlayActive = false;
let runDialog = null;
let wm = null;
let recorder = null;
@ -61,20 +61,11 @@ function start() {
}
});
overlay = new Overlay.Overlay();
panel = new Panel.Panel();
overlay = new Overlay.Overlay();
wm = new WindowManager.WindowManager();
let display = global.screen.get_display();
let toggleOverlay = function(display) {
if (overlay.visible) {
hideOverlay();
} else {
showOverlay();
}
};
global.screen.connect('toggle-recording', function() {
if (recorder == null) {
// We have to initialize GStreamer first. This isn't done
@ -92,8 +83,9 @@ function start() {
}
});
display.connect('overlay-key', toggleOverlay);
global.connect('panel-main-menu', toggleOverlay);
let display = global.screen.get_display();
display.connect('overlay-key', Lang.bind(overlay, overlay.toggle));
global.connect('panel-main-menu', Lang.bind(overlay, overlay.toggle));
// Need to update struts on new workspaces when they are added
global.screen.connect('notify::n-workspaces', _setStageArea);
@ -154,19 +146,6 @@ function endModal() {
inModal = false;
}
function showOverlay() {
if (startModal()) {
overlayActive = true;
overlay.show();
}
}
function hideOverlay() {
overlay.hide();
overlayActive = false;
endModal();
}
function createAppLaunchContext() {
let global = Shell.Global.get();
let screen = global.screen;

View File

@ -754,7 +754,7 @@ Overlay.prototype = {
// TODO - have some sort of animation/effect while
// transitioning to the new app. We definitely need
// startup-notification integration at least.
me._deactivate();
me.hide();
});
this._sideshow.connect('more-activated', function(sideshow) {
if (me._workspaces != null) {
@ -795,6 +795,8 @@ Overlay.prototype = {
show : function() {
if (this.visible)
return;
if (!Main.startModal())
return;
this.visible = true;
@ -854,6 +856,8 @@ Overlay.prototype = {
onCompleteScope: this
});
this.emit('showing');
},
hide : function() {
@ -885,6 +889,15 @@ Overlay.prototype = {
onComplete: this._hideDone,
onCompleteScope: this
});
this.emit('hiding');
},
toggle: function() {
if (this.visible)
this.hide();
else
this.show();
},
//// Private methods ////
@ -903,6 +916,8 @@ Overlay.prototype = {
this._sideshow.actor.raise_top();
this._sideshow.actor.remove_clip();
this.emit('shown');
},
_hideDone: function() {
@ -919,12 +934,12 @@ Overlay.prototype = {
this.visible = false;
this._hideInProgress = false;
},
_deactivate : function() {
Main.hideOverlay();
Main.endModal();
this.emit('hidden');
}
};
Signals.addSignalMethods(Overlay.prototype);
Tweener.registerSpecialProperty("clipHeightBottom", _clipHeightBottomGet, _clipHeightBottomSet);

View File

@ -150,14 +150,8 @@ Panel.prototype = {
// have the overlay act like a menu that allows the user to release the mouse on the activity the user wants
// to switch to.
this.button.button.connect('button-press-event',
function(o, event) {
if (Main.overlay.visible)
Main.hideOverlay();
else
Main.showOverlay();
return true;
});
Lang.bind(Main.overlay, Main.overlay.toggle));
Main.overlay.connect('hiding', Lang.bind(this.button, this.button.release));
this.actor.add_actor(box);
@ -217,9 +211,5 @@ Panel.prototype = {
this._clock.set_text(displayDate.toLocaleFormat("%a %b %e, %l:%M %p"));
Mainloop.timeout_add(msecRemaining, Lang.bind(this, this._updateClock));
return false;
},
overlayHidden: function() {
this.button.release();
}
};

View File

@ -86,7 +86,7 @@ WindowManager.prototype = {
},
_shouldAnimate : function(actor) {
if (Main.overlayActive)
if (Main.overlay.visible)
return false;
if (actor && (actor.get_window_type() != Meta.CompWindowType.NORMAL))
return false;

View File

@ -292,7 +292,7 @@ Workspace.prototype = {
Lang.bind(this,
function(clone, time) {
this._metaWorkspace.activate(time);
Main.hideOverlay();
Main.overlay.hide();
}));
this.actor.add_actor(this._desktop.actor);
@ -721,7 +721,7 @@ Workspace.prototype = {
workspace.activate_with_focus(clone.metaWindow, time);
} else
clone.metaWindow.activate(time);
Main.hideOverlay();
Main.overlay.hide();
},
_removeSelf : function(actor, event) {