From 06d5973851ac6ef3f6dc2387abe39d32632e3d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 9 Jul 2020 21:21:55 +0200 Subject: [PATCH] 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 --- src/core/main-private.h | 6 ++++++ src/core/main.c | 27 ++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/core/main-private.h b/src/core/main-private.h index be6b1cef3..c37ce8cd6 100644 --- a/src/core/main-private.h +++ b/src/core/main-private.h @@ -51,4 +51,10 @@ void meta_override_compositor_configuration (MetaCompositorType compositor_type, 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 */ diff --git a/src/core/main.c b/src/core/main.c index 16ab6e81f..2a7cb4eaf 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -642,6 +642,22 @@ meta_register_with_session (void) 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) * @@ -653,15 +669,8 @@ meta_register_with_session (void) int meta_run (void) { - /* Load prefs */ - meta_prefs_init (); - 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_start (); + meta_run_main_loop (); meta_finalize (); return meta_exit_code;