1
0
Fork 0
mutter-performance-source/src/core/restart-helper.c
Owen W. Taylor 3a57f843d5 Add a framework for restarting the compositor with nice visuals
The current GNOME Shell Alt-F2 restart looks very messy and also
provides no indication to the user what is going on. We need to
restart the compositor to switch in and out of stereo mode, so
add a framework for doing this more cleanly:

Additions:

 meta_restart(): restarts the compositor with a message
 MetaDisplay::show-restart-message: signal the embedding
    shell to show a message
 MetaDisplay::restart: signal the embedding shell to restart
    itself.
 meta_is_restart(): indicates whether the current instance is a
                    restart so we can suppress login animations.

A helper program meta-restart-helper holds the composite overlay
window up during the restart to avoid visual artifacts.

https://bugzilla.gnome.org/show_bug.cgi?id=733026
2014-07-16 18:09:25 -04:00

82 lines
2.3 KiB
C

/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* SECTION:restart-helper
* @short_description: helper program during a restart
*
* To smoothly restart Mutter, we want to keep the composite
* overlay window enabled during the restart. This is done by
* spawning this program, which keeps a reference to the the composite
* overlay window until Mutter picks it back up.
*/
/*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xcomposite.h>
int
main (int argc,
char **argv)
{
Display *display = XOpenDisplay (NULL);
Window selection_window;
XSetWindowAttributes xwa;
unsigned long mask = 0;
xwa.override_redirect = True;
mask |= CWOverrideRedirect;
XCompositeGetOverlayWindow (display, DefaultRootWindow (display));
selection_window = XCreateWindow (display,
DefaultRootWindow (display),
-100, -100, 1, 1, 0,
0,
InputOnly,
DefaultVisual (display, DefaultScreen (display)),
mask, &xwa);
XSetSelectionOwner (display,
XInternAtom (display, "_MUTTER_RESTART_HELPER", False),
selection_window,
CurrentTime);
/* Mutter looks for an (arbitrary) line printed to stdout to know that
* we have started and have a reference to the COW. XSync() so that
* everything is set on the X server before Mutter starts restarting.
*/
XSync (display, False);
printf ("STARTED\n");
fflush (stdout);
while (True)
{
XEvent xev;
XNextEvent (display, &xev);
/* Mutter restarted and unset the selection to indicate that
* it has a reference on the COW again */
if (xev.xany.type == SelectionClear)
return 0;
}
}