Create ShellGlobal later to avoid connecting to X during build

The ShellGlobal initialization performs several actions like connecting
to the X server, ensuring directories exist, etc., that are problematic
because we were creating the object even when running the binary for
introspection scanning.  During compilation we may not even have X11
available in e.g. autobuilder type environments, and it's just a
bad idea to connect even if we do.

Avoid this by deferring creation of the ShellGlobal object
until the plugin is actually started.

Now that we're initializing things later, remove the connection to
screen changes, and initialize cached ShellGlobal state at the point
when the plugin is set.  The root pixmap actor is now sized initially
on creation too.  Instead of relying on screen-size-changed being
emitted on startup, explicitly invoke _relayout().

https://bugzilla.gnome.org/show_bug.cgi?id=618371
This commit is contained in:
Colin Walters 2010-05-11 10:35:27 -04:00
parent f438ccfc53
commit 84716bccd4
3 changed files with 43 additions and 36 deletions

View File

@ -167,6 +167,9 @@ function start() {
// Install magnifier.
magnifier = new Magnifier.Magnifier();
// Perform initial relayout here
_relayout();
_log('info', 'loaded at ' + _startDate);
log('GNOME Shell started at ' + _startDate);

View File

@ -140,8 +140,6 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
static void
gnome_shell_plugin_init (GnomeShellPlugin *shell_plugin)
{
_shell_global_set_plugin (shell_global_get(), MUTTER_PLUGIN(shell_plugin));
meta_prefs_override_preference_location ("/apps/metacity/general/button_layout",
"/desktop/gnome/shell/windows/button_layout");
}
@ -245,6 +243,7 @@ gnome_shell_plugin_start (MutterPlugin *plugin)
int status;
const char *shell_js;
char **search_path;
ShellGlobal *global;
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@ -275,7 +274,11 @@ gnome_shell_plugin_start (MutterPlugin *plugin)
shell_plugin->gjs_context = gjs_context_new_with_search_path(search_path);
g_strfreev(search_path);
_shell_global_set_gjs_context (shell_global_get (), shell_plugin->gjs_context);
/* Initialize the global object here. */
global = shell_global_get ();
_shell_global_set_plugin (global, MUTTER_PLUGIN(shell_plugin));
_shell_global_set_gjs_context (global, shell_plugin->gjs_context);
if (!gjs_context_eval (shell_plugin->gjs_context,
"const Main = imports.ui.main; Main.start();",

View File

@ -436,24 +436,33 @@ shell_global_get_windows (ShellGlobal *global)
}
static gboolean
on_screen_size_changed_cb (gpointer data)
update_screen_size (ShellGlobal *global)
{
ShellGlobal *global = SHELL_GLOBAL (data);
int width, height;
mutter_plugin_query_screen_size (global->plugin, &width, &height);
if (global->last_change_screen_width != width || global->last_change_screen_height != height)
{
g_signal_emit (G_OBJECT (global), shell_global_signals[SCREEN_SIZE_CHANGED], 0);
global->last_change_screen_width = width;
global->last_change_screen_height = height;
if (global->last_change_screen_width == width && global->last_change_screen_height == height)
return FALSE;
/* update size of background actor to fix tiled backgrounds */
clutter_actor_set_size (CLUTTER_ACTOR (global->root_pixmap),
width, height);
}
global->last_change_screen_width = width;
global->last_change_screen_height = height;
/* update size of background actor to fix tiled backgrounds */
if (global->root_pixmap)
clutter_actor_set_size (CLUTTER_ACTOR (global->root_pixmap),
width, height);
return TRUE;
}
static gboolean
on_screen_size_changed_cb (gpointer data)
{
ShellGlobal *global = SHELL_GLOBAL (data);
if (update_screen_size (global))
g_signal_emit (G_OBJECT (global), shell_global_signals[SCREEN_SIZE_CHANGED], 0);
return FALSE;
}
@ -488,37 +497,25 @@ global_stage_notify_height (GObject *gobject,
NULL);
}
static void
global_plugin_notify_screen (GObject *gobject,
GParamSpec *pspec,
gpointer data)
{
ShellGlobal *global = SHELL_GLOBAL (data);
ClutterActor *stage = mutter_plugin_get_stage (MUTTER_PLUGIN (gobject));
g_signal_connect (stage, "notify::width",
G_CALLBACK (global_stage_notify_width), global);
g_signal_connect (stage, "notify::height",
G_CALLBACK (global_stage_notify_height), global);
}
void
_shell_global_set_plugin (ShellGlobal *global,
MutterPlugin *plugin)
{
ClutterActor *stage;
g_return_if_fail (SHELL_IS_GLOBAL (global));
g_return_if_fail (global->plugin == NULL);
global->plugin = plugin;
global->wm = shell_wm_new (plugin);
/* At this point screen is NULL, so we can't yet do signal connections
* to the width and height; we wait until the screen property is set
* to do that. Note that this is a one time thing - screen will never
* change once first set.
*/
g_signal_connect (plugin, "notify::screen",
G_CALLBACK (global_plugin_notify_screen), global);
stage = mutter_plugin_get_stage (plugin);
g_signal_connect (stage, "notify::width",
G_CALLBACK (global_stage_notify_width), global);
g_signal_connect (stage, "notify::height",
G_CALLBACK (global_stage_notify_height), global);
update_screen_size (global);
}
void
@ -1023,6 +1020,10 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global)
{
global->root_pixmap = clutter_glx_texture_pixmap_new ();
clutter_actor_set_size (CLUTTER_ACTOR (global->root_pixmap),
global->last_change_screen_width,
global->last_change_screen_height);
clutter_texture_set_repeat (CLUTTER_TEXTURE (global->root_pixmap),
TRUE, TRUE);