Add support for meta_restart() and MetaDisplay::restart

Support was added to Mutter to allow it to trigger a restart
to allow for restarts when switching in or out of stereo mode.

Hook up to the new signals on MetaDisplay to show the restart
message and reexec. Meta.is_restart() is used to suppress
the startup animation.

This also allows us to do 'Alt-F2 r' restarts more cleanly
without a visual flash and animation.
This commit is contained in:
Owen W. Taylor 2014-05-08 18:56:23 -04:00
parent e4e3252ffc
commit b80641f45d
5 changed files with 76 additions and 22 deletions

View File

@ -2057,6 +2057,11 @@ StScrollBar StButton#vhandle:active {
font-size: 10pt; font-size: 10pt;
} }
/* Restart message */
.restart-message {
font-size: 14pt;
}
/* ShellMountOperation Dialogs */ /* ShellMountOperation Dialogs */
.shell-mount-operation-icon { .shell-mount-operation-icon {
icon-size: 48px; icon-size: 48px;

View File

@ -597,7 +597,9 @@ const LayoutManager = new Lang.Class({
reactive: true }); reactive: true });
this.addChrome(this._coverPane); this.addChrome(this._coverPane);
if (Main.sessionMode.isGreeter) { if (Meta.is_restart()) {
// On restart, we don't do an animation
} else if (Main.sessionMode.isGreeter) {
this.panelBox.translation_y = -this.panelBox.height; this.panelBox.translation_y = -this.panelBox.height;
} else { } else {
this._updateBackgrounds(); this._updateBackgrounds();
@ -635,7 +637,9 @@ const LayoutManager = new Lang.Class({
}, },
_startupAnimation: function() { _startupAnimation: function() {
if (Main.sessionMode.isGreeter) if (Meta.is_restart())
this._startupAnimationComplete();
else if (Main.sessionMode.isGreeter)
this._startupAnimationGreeter(); this._startupAnimationGreeter();
else else
this._startupAnimationSession(); this._startupAnimationSession();

View File

@ -18,6 +18,7 @@ const ExtensionSystem = imports.ui.extensionSystem;
const ExtensionDownloader = imports.ui.extensionDownloader; const ExtensionDownloader = imports.ui.extensionDownloader;
const Keyboard = imports.ui.keyboard; const Keyboard = imports.ui.keyboard;
const MessageTray = imports.ui.messageTray; const MessageTray = imports.ui.messageTray;
const ModalDialog = imports.ui.modalDialog;
const OsdWindow = imports.ui.osdWindow; const OsdWindow = imports.ui.osdWindow;
const Overview = imports.ui.overview; const Overview = imports.ui.overview;
const Panel = imports.ui.panel; const Panel = imports.ui.panel;
@ -182,6 +183,16 @@ function _initializeUI() {
overview.toggle(); overview.toggle();
})); }));
global.display.connect('show-restart-message', function(display, message) {
showRestartMessage(message);
return true;
});
global.display.connect('restart', function() {
global.reexec_self();
return true;
});
// Provide the bus object for gnome-session to // Provide the bus object for gnome-session to
// initiate logouts. // initiate logouts.
EndSessionDialog.init(); EndSessionDialog.init();
@ -613,3 +624,28 @@ function queueDeferredWork(workId) {
}); });
} }
} }
const RestartMessage = new Lang.Class({
Name: 'RestartMessage',
Extends: ModalDialog.ModalDialog,
_init : function(message) {
this.parent({ shellReactive: true,
styleClass: 'restart-message',
shouldFadeIn: false,
destroyOnClose: true });
let label = new St.Label({ text: message });
this.contentLayout.add(label, { x_fill: false,
y_fill: false,
x_align: St.Align.MIDDLE,
y_align: St.Align.MIDDLE });
this.buttonLayout.hide();
}
});
function showRestartMessage(message) {
let restartMessage = new RestartMessage(message);
restartMessage.open();
}

View File

@ -43,6 +43,7 @@ const ModalDialog = new Lang.Class({
styleClass: null, styleClass: null,
keybindingMode: Shell.KeyBindingMode.SYSTEM_MODAL, keybindingMode: Shell.KeyBindingMode.SYSTEM_MODAL,
shouldFadeIn: true, shouldFadeIn: true,
shouldFadeOut: true,
destroyOnClose: true }); destroyOnClose: true });
this.state = State.CLOSED; this.state = State.CLOSED;
@ -50,6 +51,7 @@ const ModalDialog = new Lang.Class({
this._keybindingMode = params.keybindingMode; this._keybindingMode = params.keybindingMode;
this._shellReactive = params.shellReactive; this._shellReactive = params.shellReactive;
this._shouldFadeIn = params.shouldFadeIn; this._shouldFadeIn = params.shouldFadeIn;
this._shouldFadeOut = params.shouldFadeOut;
this._destroyOnClose = params.destroyOnClose; this._destroyOnClose = params.destroyOnClose;
this._group = new St.Widget({ visible: false, this._group = new St.Widget({ visible: false,
@ -307,6 +309,15 @@ const ModalDialog = new Lang.Class({
return true; return true;
}, },
_closeComplete: function() {
this.state = State.CLOSED;
this._group.hide();
this.emit('closed');
if (this._destroyOnClose)
this.destroy();
},
close: function(timestamp) { close: function(timestamp) {
if (this.state == State.CLOSED || this.state == State.CLOSING) if (this.state == State.CLOSED || this.state == State.CLOSING)
return; return;
@ -315,20 +326,16 @@ const ModalDialog = new Lang.Class({
this.popModal(timestamp); this.popModal(timestamp);
this._savedKeyFocus = null; this._savedKeyFocus = null;
if (this._shouldFadeOut)
Tweener.addTween(this._group, Tweener.addTween(this._group,
{ opacity: 0, { opacity: 0,
time: OPEN_AND_CLOSE_TIME, time: OPEN_AND_CLOSE_TIME,
transition: 'easeOutQuad', transition: 'easeOutQuad',
onComplete: Lang.bind(this, onComplete: Lang.bind(this,
function() { this._closeComplete)
this.state = State.CLOSED;
this._group.hide();
this.emit('closed');
if (this._destroyOnClose)
this.destroy();
}) })
}); else
this._closeComplete();
}, },
// Drop modal status without closing the dialog; this makes the // Drop modal status without closing the dialog; this makes the

View File

@ -50,14 +50,10 @@ const RunDialog = new Lang.Class({
Main.createLookingGlass().open(); Main.createLookingGlass().open();
}), }),
'r': Lang.bind(this, function() { 'r': Lang.bind(this, this._restart),
global.reexec_self();
}),
// Developer brain backwards compatibility // Developer brain backwards compatibility
'restart': Lang.bind(this, function() { 'restart': Lang.bind(this, this._restart),
global.reexec_self();
}),
'debugexit': Lang.bind(this, function() { 'debugexit': Lang.bind(this, function() {
Meta.quit(Meta.ExitCode.ERROR); Meta.quit(Meta.ExitCode.ERROR);
@ -271,6 +267,12 @@ const RunDialog = new Lang.Class({
} }
}, },
_restart: function() {
this._shouldFadeOut = false;
this.close();
Meta.restart('Restarting...');
},
open: function() { open: function() {
this._history.lastItem(); this._history.lastItem();
this._errorBox.hide(); this._errorBox.hide();