main: Split up meta_run() into meta_start() and meta_run_main_loop()

meta_run() is still left intact and does the same as before; the new
functions are only intended to be used by tests, as they may need to set
things up after starting up. Doing so linearly in the test case is much
easier than adding callbacks, so meta_run() is split up to make this
possible.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
This commit is contained in:
Jonas Ådahl 2020-07-09 21:21:55 +02:00
parent ebfa94f360
commit 06d5973851
2 changed files with 24 additions and 9 deletions

View File

@ -51,4 +51,10 @@ void meta_override_compositor_configuration (MetaCompositorType compositor_type,
MetaDisplayPolicy meta_get_x11_display_policy (void); MetaDisplayPolicy meta_get_x11_display_policy (void);
META_EXPORT_TEST
void meta_start (void);
META_EXPORT_TEST
void meta_run_main_loop (void);
#endif /* META_MAIN_PRIVATE_H */ #endif /* META_MAIN_PRIVATE_H */

View File

@ -642,6 +642,22 @@ meta_register_with_session (void)
g_free (opt_client_id); g_free (opt_client_id);
} }
void
meta_start (void)
{
meta_prefs_init ();
meta_prefs_add_listener (prefs_changed_callback, NULL);
if (!meta_display_open ())
meta_exit (META_EXIT_ERROR);
}
void
meta_run_main_loop (void)
{
g_main_loop_run (meta_main_loop);
}
/** /**
* meta_run: (skip) * meta_run: (skip)
* *
@ -653,15 +669,8 @@ meta_register_with_session (void)
int int
meta_run (void) meta_run (void)
{ {
/* Load prefs */ meta_start ();
meta_prefs_init (); meta_run_main_loop ();
meta_prefs_add_listener (prefs_changed_callback, NULL);
if (!meta_display_open ())
meta_exit (META_EXIT_ERROR);
g_main_loop_run (meta_main_loop);
meta_finalize (); meta_finalize ();
return meta_exit_code; return meta_exit_code;