static void meta_backend_x11_post_init (MetaBackend *backend) { MetaBackendX11 *x11 = META_BACKEND_X11 (backend); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); int major, minor; priv->xdisplay = clutter_x11_get_default_display (); priv->source = x_event_source_new (backend); if (!XSyncQueryExtension (priv->xdisplay, &priv->xsync_event_base, &priv->xsync_error_base) || !XSyncInitialize (priv->xdisplay, &major, &minor)) meta_fatal ("Could not initialize XSync"); { int major = 2, minor = 3; gboolean has_xi = FALSE; if (XQueryExtension (priv->xdisplay, "XInputExtension", &priv->xinput_opcode, &priv->xinput_error_base, &priv->xinput_event_base)) { if (XIQueryVersion (priv->xdisplay, &major, &minor) == Success) { int version = (major * 10) + minor; if (version >= 22) has_xi = TRUE; } } if (!has_xi) meta_fatal ("X server doesn't have the XInput extension, version 2.2 or newer\n"); } take_touch_grab (backend); priv->xcb = XGetXCBConnection (priv->xdisplay); if (!xkb_x11_setup_xkb_extension (priv->xcb, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION, XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS, NULL, NULL, &priv->xkb_event_base, &priv->xkb_error_base)) meta_fatal ("X server doesn't have the XKB extension, version %d.%d or newer\n", XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION); g_signal_connect_object (clutter_device_manager_get_default (), "device-added", G_CALLBACK (on_device_added), backend, 0); META_BACKEND_CLASS (meta_backend_x11_parent_class)->post_init (backend); }
/** * meta_run: (skip) * * Runs mutter. Call this after completing initialization that doesn't require * an event loop. * * Return value: mutter's exit status */ int meta_run (void) { /* Load prefs */ meta_prefs_init (); meta_prefs_add_listener (prefs_changed_callback, NULL); meta_ui_set_current_theme (meta_prefs_get_theme ()); /* Try to find some theme that'll work if the theme preference * doesn't exist. First try Simple (the default theme) then just * try anything in the themes directory. */ if (!meta_ui_have_a_theme ()) meta_ui_set_current_theme ("Simple"); if (!meta_ui_have_a_theme ()) { const char *dir_entry = NULL; GError *err = NULL; GDir *themes_dir = NULL; if (!(themes_dir = g_dir_open (MUTTER_DATADIR"/themes", 0, &err))) { meta_fatal (_("Failed to scan themes directory: %s\n"), err->message); g_error_free (err); } else { while (((dir_entry = g_dir_read_name (themes_dir)) != NULL) && (!meta_ui_have_a_theme ())) { meta_ui_set_current_theme (dir_entry); } g_dir_close (themes_dir); } } if (!meta_ui_have_a_theme ()) meta_fatal (_("Could not find a theme! Be sure %s exists and contains the usual themes.\n"), MUTTER_DATADIR"/themes"); if (!meta_display_open ()) meta_exit (META_EXIT_ERROR); g_main_loop_run (meta_main_loop); meta_finalize (); return meta_exit_code; }
void meta_plugin_manager_set_plugin_type (GType gtype) { if (plugin_type != G_TYPE_NONE) meta_fatal ("Mutter plugin already set: %s", g_type_name (plugin_type)); plugin_type = gtype; }
void meta_ui_init (int *argc, char ***argv) { if (!gtk_init_check (argc, argv)) meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL)); meta_stock_icons_init (); }
void meta_ui_init (void) { if (!gtk_init_check (NULL, NULL)) meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL)); /* We need to be able to fully trust that the window and monitor sizes that Gdk reports corresponds to the X ones, so we disable the automatic scale handling */ gdk_x11_display_set_window_scale (gdk_display_get_default (), 1); }
void meta_ui_init(int* argc, char*** argv) { /* As of 2.91.7, Gdk uses XI2 by default, which conflicts with the * direct X calls we use - in particular, events caused by calls to * XGrabPointer/XGrabKeyboard are no longer understood by GDK, while * GDK will no longer generate the core XEvents we process. * So at least for now, enforce the previous behavior. */ #if GTK_CHECK_VERSION(2, 91, 7) gdk_disable_multidevice (); #endif if (!gtk_init_check (argc, argv)) { meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL)); } }
static void meta_clutter_init (void) { clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); clutter_x11_disable_event_retrieval (); if (CLUTTER_INIT_SUCCESS == clutter_init (NULL, NULL)) { GSource *source = g_source_new (&event_funcs, sizeof (GSource)); g_source_attach (source, NULL); g_source_unref (source); } else { meta_fatal ("Unable to initialize Clutter.\n"); } }
static void redirect_windows (MetaScreen *screen) { MetaDisplay *display = meta_screen_get_display (screen); Display *xdisplay = meta_display_get_xdisplay (display); Window xroot = meta_screen_get_xroot (screen); int screen_number = meta_screen_get_screen_number (screen); guint n_retries; guint max_retries; if (meta_get_replace_current_wm ()) max_retries = 5; else max_retries = 1; n_retries = 0; /* Some compositors (like old versions of Mutter) might not properly unredirect * subwindows before destroying the WM selection window; so we wait a while * for such a compositor to exit before giving up. */ while (TRUE) { meta_error_trap_push (display); XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual); XSync (xdisplay, FALSE); if (!meta_error_trap_pop_with_return (display)) break; if (n_retries == max_retries) { /* This probably means that a non-WM compositor like xcompmgr is running; * we have no way to get it to exit */ meta_fatal (_("Another compositing manager is already running on screen %i on display \"%s\"."), screen_number, display->name); } n_retries++; g_usleep (G_USEC_PER_SEC); } }
void meta_ui_init (void) { const char *gdk_gl_env = NULL; gdk_set_allowed_backends ("x11"); gdk_gl_env = g_getenv ("GDK_GL"); g_setenv("GDK_GL", "disable", TRUE); if (!gtk_init_check (NULL, NULL)) meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL)); if (gdk_gl_env) g_setenv("GDK_GL", gdk_gl_env, TRUE); else unsetenv("GDK_GL"); /* We need to be able to fully trust that the window and monitor sizes that Gdk reports corresponds to the X ones, so we disable the automatic scale handling */ gdk_x11_display_set_window_scale (gdk_display_get_default (), 1); }
/** * meta_init: (skip) * * Initialize mutter. Call this after meta_get_option_context() and * meta_plugin_manager_set_plugin_type(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif g_unix_signal_add (SIGTERM, on_sigterm, NULL); if (g_getenv ("MUTTER_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUTTER_DEBUG")) meta_set_debugging (TRUE); #if defined(CLUTTER_WINDOWING_EGL) && defined(HAVE_NATIVE_BACKEND) if (opt_display_server) clutter_set_windowing_backend (CLUTTER_WINDOWING_EGL); else #endif clutter_set_windowing_backend (CLUTTER_WINDOWING_X11); #ifdef HAVE_WAYLAND meta_set_is_wayland_compositor (opt_wayland); #endif if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUTTER_PKGLIBDIR); #endif #ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) meta_wayland_pre_clutter_init (); #endif /* NB: When running as a hybrid wayland compositor we run our own headless X * server so the user can't control the X display to connect too. */ if (!meta_is_wayland_compositor ()) meta_select_display (opt_display_name); meta_clutter_init (); #ifdef HAVE_WAYLAND /* Bring up Wayland. This also launches Xwayland and sets DISPLAY as well... */ if (meta_is_wayland_compositor ()) meta_wayland_init (); #endif meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL)); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); meta_restart_init (); }
/** * meta_run: (skip) * * Runs muffin. Call this after completing your own initialization. * * Return value: muffin's exit status */ int meta_run (void) { const gchar *log_domains[] = { NULL, G_LOG_DOMAIN, "Gtk", "Gdk", "GLib", "Pango", "GLib-GObject", "GThread" }; guint i; /* Load prefs */ meta_prefs_init (); meta_prefs_add_listener (prefs_changed_callback, NULL); for (i=0; i<G_N_ELEMENTS(log_domains); i++) g_log_set_handler (log_domains[i], G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_handler, NULL); if (g_getenv ("MUFFIN_G_FATAL_WARNINGS") != NULL) g_log_set_always_fatal (G_LOG_LEVEL_MASK); meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE); /* Try to find some theme that'll work if the theme preference * doesn't exist. First try Simple (the default theme) then just * try anything in the themes directory. */ if (!meta_ui_have_a_theme ()) meta_ui_set_current_theme ("Simple", FALSE); if (!meta_ui_have_a_theme ()) { const char *dir_entry = NULL; GError *err = NULL; GDir *themes_dir = NULL; if (!(themes_dir = g_dir_open (MUFFIN_DATADIR"/themes", 0, &err))) { meta_fatal (_("Failed to scan themes directory: %s\n"), err->message); g_error_free (err); } else { while (((dir_entry = g_dir_read_name (themes_dir)) != NULL) && (!meta_ui_have_a_theme ())) { meta_ui_set_current_theme (dir_entry, FALSE); } g_dir_close (themes_dir); } } if (!meta_ui_have_a_theme ()) meta_fatal (_("Could not find a theme! Be sure %s exists and contains the usual themes.\n"), MUFFIN_DATADIR"/themes"); /* Connect to SM as late as possible - but before managing display, * or we might try to manage a window before we have the session * info */ if (!opt_disable_sm) { if (opt_client_id == NULL) { const gchar *desktop_autostart_id; desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID"); if (desktop_autostart_id != NULL) opt_client_id = g_strdup (desktop_autostart_id); } /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to * use the same client id. */ g_unsetenv ("DESKTOP_AUTOSTART_ID"); meta_session_init (opt_client_id, opt_save_file); } /* Free memory possibly allocated by the argument parsing which are * no longer needed. */ g_free (opt_save_file); g_free (opt_display_name); g_free (opt_client_id); if (!meta_display_open ()) meta_exit (META_EXIT_ERROR); g_main_loop_run (meta_main_loop); meta_finalize (); return meta_exit_code; }
/** * meta_init: (skip) * * Initialize muffin. Call this after meta_get_option_context() and * meta_plugin_type_register(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; GIOChannel *channel; g_type_init (); sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif if (pipe (sigterm_pipe_fds) != 0) g_printerr ("Failed to create SIGTERM pipe: %s\n", g_strerror (errno)); channel = g_io_channel_unix_new (sigterm_pipe_fds[0]); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_sigterm, NULL); g_io_channel_set_close_on_unref (channel, TRUE); g_io_channel_unref (channel); act.sa_handler = &sigterm_handler; if (sigaction (SIGTERM, &act, NULL) < 0) g_printerr ("Failed to register SIGTERM handler: %s\n", g_strerror (errno)); if (g_getenv ("MUFFIN_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUFFIN_DEBUG")) meta_set_debugging (TRUE); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUFFIN_PKGLIBDIR); #endif meta_set_syncing (opt_sync || (g_getenv ("MUFFIN_SYNC") != NULL)); meta_select_display (opt_display_name); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); /* * Clutter can only be initialized after the UI. */ meta_clutter_init (); }
/** * This is where the story begins. It parses commandline options and * environment variables, sets up the screen, hands control off to * GTK, and cleans up afterwards. * * \param argc Number of arguments (as usual) * \param argv Array of arguments (as usual) * * \bug It's a bit long. It would be good to split it out into separate * functions. */ int main (int argc, char **argv) { struct sigaction act; sigset_t empty_mask; MetaArguments meta_args; const gchar *log_domains[] = { NULL, G_LOG_DOMAIN, "Gtk", "Gdk", "GLib", "Pango", "GLib-GObject", "GThread" }; guint i; GIOChannel *channel; if (setlocale (LC_ALL, "") == NULL) meta_warning ("Locale not understood by C library, internationalization will not work\n"); sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif if (pipe (sigterm_pipe_fds) != 0) g_printerr ("Failed to create SIGTERM pipe: %s\n", g_strerror (errno)); channel = g_io_channel_unix_new (sigterm_pipe_fds[0]); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_sigterm, NULL); g_io_channel_set_close_on_unref (channel, TRUE); g_io_channel_unref (channel); act.sa_handler = &sigterm_handler; if (sigaction (SIGTERM, &act, NULL) < 0) g_printerr ("Failed to register SIGTERM handler: %s\n", g_strerror (errno)); if (g_getenv ("METACITY_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("METACITY_DEBUG")) meta_set_debugging (TRUE); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); bindtextdomain (GETTEXT_PACKAGE, METACITY_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Parse command line arguments.*/ meta_parse_options (&argc, &argv, &meta_args); meta_set_syncing (meta_args.sync || (g_getenv ("METACITY_SYNC") != NULL)); if (meta_args.print_version) version (); meta_select_display (meta_args.display_name); if (meta_args.replace_wm) meta_set_replace_current_wm (TRUE); if (meta_args.save_file && meta_args.client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (&argc, &argv); /* must be after UI init so we can override GDK handlers */ meta_errors_init (); /* Load prefs */ meta_prefs_init (); meta_prefs_add_listener (prefs_changed_callback, NULL); #if 1 for (i=0; i<G_N_ELEMENTS(log_domains); i++) g_log_set_handler (log_domains[i], G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_handler, NULL); #endif if (g_getenv ("METACITY_G_FATAL_WARNINGS") != NULL) g_log_set_always_fatal (G_LOG_LEVEL_MASK); meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE); /* Try to find some theme that'll work if the theme preference * doesn't exist. First try Simple (the default theme) then just * try anything in the themes directory. */ if (!meta_ui_have_a_theme ()) meta_ui_set_current_theme ("Simple", FALSE); if (!meta_ui_have_a_theme ()) { const char *dir_entry = NULL; GError *err = NULL; GDir *themes_dir = NULL; if (!(themes_dir = g_dir_open (METACITY_DATADIR"/themes", 0, &err))) { meta_fatal (_("Failed to scan themes directory: %s\n"), err->message); g_error_free (err); } else { while (((dir_entry = g_dir_read_name (themes_dir)) != NULL) && (!meta_ui_have_a_theme ())) { meta_ui_set_current_theme (dir_entry, FALSE); } g_dir_close (themes_dir); } } if (!meta_ui_have_a_theme ()) meta_fatal (_("Could not find a theme! Be sure %s exists and contains the usual themes.\n"), METACITY_DATADIR"/themes"); /* Connect to SM as late as possible - but before managing display, * or we might try to manage a window before we have the session * info */ if (!meta_args.disable_sm) { if (meta_args.client_id == NULL) { const gchar *desktop_autostart_id; desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID"); if (desktop_autostart_id != NULL) meta_args.client_id = g_strdup (desktop_autostart_id); } /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to * use the same client id. */ g_unsetenv ("DESKTOP_AUTOSTART_ID"); meta_session_init (meta_args.client_id, meta_args.save_file); } /* Free memory possibly allocated by the argument parsing which are * no longer needed. */ g_free (meta_args.save_file); g_free (meta_args.display_name); g_free (meta_args.client_id); if (meta_args.composite || meta_args.no_composite) meta_prefs_set_compositing_manager (meta_args.composite); if (meta_args.no_force_fullscreen) meta_prefs_set_force_fullscreen (FALSE); if (!meta_display_open ()) meta_exit (META_EXIT_ERROR); g_main_loop_run (meta_main_loop); meta_finalize (); if (meta_restart_after_quit) { GError *err; err = NULL; if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &err)) { meta_fatal (_("Failed to restart: %s\n"), err->message); g_error_free (err); /* not reached anyhow */ meta_exit_code = META_EXIT_ERROR; } } return meta_exit_code; }
/** * meta_init: (skip) * * Initialize mutter. Call this after meta_get_option_context() and * meta_plugin_manager_set_plugin_type(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; ClutterSettings *clutter_settings; sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif g_unix_signal_add (SIGTERM, on_sigterm, NULL); if (g_getenv ("MUTTER_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUTTER_DEBUG")) meta_set_debugging (TRUE); #if defined(CLUTTER_WINDOWING_EGL) && defined(HAVE_NATIVE_BACKEND) if (opt_display_server) clutter_set_windowing_backend (CLUTTER_WINDOWING_EGL); #endif meta_set_is_wayland_compositor (opt_wayland); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUTTER_PKGLIBDIR); #endif if (meta_is_wayland_compositor ()) { /* NB: When running as a hybrid wayland compositor we run our own headless X * server so the user can't control the X display to connect too. */ meta_wayland_init (); } else meta_select_display (opt_display_name); meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL)); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); /* If we are running with wayland then we don't wait until we have * an X connection before initializing clutter we instead initialize * it earlier since we need to initialize the GL driver so the driver * can register any needed wayland extensions. */ if (!meta_is_wayland_compositor ()) { /* * Clutter can only be initialized after the UI. */ meta_clutter_init (); } meta_restart_init (); /* * XXX: We cannot handle high dpi scaling yet, so fix the scale to 1 * for now. */ clutter_settings = clutter_settings_get_default (); g_object_set (clutter_settings, "window-scaling-factor", 1, NULL); }
/** * meta_run: (skip) * * Runs mutter. Call this after completing initialization that doesn't require * an event loop. * * Return value: mutter's exit status */ int meta_run (void) { const gchar *log_domains[] = { NULL, G_LOG_DOMAIN, "Gtk", "Gdk", "GLib", "Pango", "GLib-GObject", "GThread" }; guint i; /* Load prefs */ meta_prefs_init (); meta_prefs_add_listener (prefs_changed_callback, NULL); for (i=0; i<G_N_ELEMENTS(log_domains); i++) g_log_set_handler (log_domains[i], G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, log_handler, NULL); if (g_getenv ("MUTTER_G_FATAL_WARNINGS") != NULL) g_log_set_always_fatal (G_LOG_LEVEL_MASK); meta_ui_set_current_theme (meta_prefs_get_theme ()); /* Try to find some theme that'll work if the theme preference * doesn't exist. First try Simple (the default theme) then just * try anything in the themes directory. */ if (!meta_ui_have_a_theme ()) meta_ui_set_current_theme ("Simple"); if (!meta_ui_have_a_theme ()) { const char *dir_entry = NULL; GError *err = NULL; GDir *themes_dir = NULL; if (!(themes_dir = g_dir_open (MUTTER_DATADIR"/themes", 0, &err))) { meta_fatal (_("Failed to scan themes directory: %s\n"), err->message); g_error_free (err); } else { while (((dir_entry = g_dir_read_name (themes_dir)) != NULL) && (!meta_ui_have_a_theme ())) { meta_ui_set_current_theme (dir_entry); } g_dir_close (themes_dir); } } if (!meta_ui_have_a_theme ()) meta_fatal (_("Could not find a theme! Be sure %s exists and contains the usual themes.\n"), MUTTER_DATADIR"/themes"); if (!meta_display_open ()) meta_exit (META_EXIT_ERROR); g_main_loop_run (meta_main_loop); meta_finalize (); return meta_exit_code; }
/** * meta_init: (skip) * * Initialize muffin. Call this after meta_get_option_context() and * meta_plugin_manager_set_plugin_type(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; GIOChannel *channel; sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif if (pipe (sigterm_pipe_fds) != 0) g_printerr ("Failed to create SIGTERM pipe: %s\n", g_strerror (errno)); channel = g_io_channel_unix_new (sigterm_pipe_fds[0]); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_sigterm, NULL); g_io_channel_set_close_on_unref (channel, TRUE); g_io_channel_unref (channel); act.sa_handler = &sigterm_handler; if (sigaction (SIGTERM, &act, NULL) < 0) g_printerr ("Failed to register SIGTERM handler: %s\n", g_strerror (errno)); if (g_getenv ("MUFFIN_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUFFIN_DEBUG")) meta_set_debugging (TRUE); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUFFIN_PKGLIBDIR); #endif meta_set_syncing (opt_sync || (g_getenv ("MUFFIN_SYNC") != NULL)); meta_select_display (opt_display_name); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); /* * Clutter can only be initialized after the UI. */ meta_clutter_init (); const char *renderer = (const char *) glGetString (GL_RENDERER); if (strstr (renderer, "llvmpipe") || strstr (renderer, "Rasterizer") || strstr (renderer, "softpipe")) { /* Clutter envs not set, since they won't work after Clutter init */ g_setenv ("CINNAMON_SOFTWARE_RENDERING", "1", FALSE); g_setenv ("CINNAMON_SLOWDOWN_FACTOR", "0.0001", FALSE); g_setenv ("MUFFIN_NO_SHADOWS", "1", FALSE); meta_warning ("Software rendering detected: %s\n", renderer); } }
void meta_compositor_manage_screen (MetaCompositor *compositor, MetaScreen *screen) { MetaCompScreen *info; MetaDisplay *display = meta_screen_get_display (screen); Display *xdisplay = meta_display_get_xdisplay (display); int screen_number = meta_screen_get_screen_number (screen); Window xroot = meta_screen_get_xroot (screen); Window xwin; gint width, height; XWindowAttributes attr; long event_mask; guint n_retries; guint max_retries; /* Check if the screen is already managed */ if (meta_screen_get_compositor_data (screen)) return; if (meta_get_replace_current_wm ()) max_retries = 5; else max_retries = 1; n_retries = 0; /* Some compositors (like old versions of Muffin) might not properly unredirect * subwindows before destroying the WM selection window; so we wait a while * for such a compositor to exit before giving up. */ while (TRUE) { meta_error_trap_push_with_return (display); XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual); XSync (xdisplay, FALSE); if (!meta_error_trap_pop_with_return (display)) break; if (n_retries == max_retries) { /* This probably means that a non-WM compositor like xcompmgr is running; * we have no way to get it to exit */ meta_fatal (_("Another compositing manager is already running on screen %i on display \"%s\"."), screen_number, display->name); } n_retries++; g_usleep (G_USEC_PER_SEC); } info = g_new0 (MetaCompScreen, 1); /* * We use an empty input region for Clutter as a default because that allows * the user to interact with all the windows displayed on the screen. * We have to initialize info->pending_input_region to an empty region explicitly, * because None value is used to mean that the whole screen is an input region. */ info->pending_input_region = XFixesCreateRegion (xdisplay, NULL, 0); info->screen = screen; meta_screen_set_compositor_data (screen, info); info->output = None; info->windows = NULL; meta_screen_set_cm_selection (screen); info->stage = clutter_stage_new (); meta_screen_get_size (screen, &width, &height); clutter_actor_realize (info->stage); xwin = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage)); XResizeWindow (xdisplay, xwin, width, height); event_mask = FocusChangeMask | ExposureMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask | PropertyChangeMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask; if (XGetWindowAttributes (xdisplay, xwin, &attr)) { event_mask |= attr.your_event_mask; } XSelectInput (xdisplay, xwin, event_mask); info->window_group = meta_window_group_new (screen); info->background_actor = meta_background_actor_new_for_screen (screen); info->bottom_window_group = clutter_group_new(); info->overlay_group = clutter_group_new (); info->top_window_group = meta_window_group_new (screen); info->hidden_group = clutter_group_new (); clutter_container_add (CLUTTER_CONTAINER (info->window_group), info->background_actor, NULL); clutter_container_add (CLUTTER_CONTAINER (info->stage), info->window_group, info->overlay_group, info->hidden_group, NULL); clutter_actor_hide (info->hidden_group); info->plugin_mgr = meta_plugin_manager_get (screen); meta_plugin_manager_initialize (info->plugin_mgr); /* * Delay the creation of the overlay window as long as we can, to avoid * blanking out the screen. This means that during the plugin loading, the * overlay window is not accessible; if the plugin needs to access it * directly, it should hook into the "show" signal on stage, and do * its stuff there. */ info->output = get_output_window (screen); XReparentWindow (xdisplay, xwin, info->output, 0, 0); /* Make sure there isn't any left-over output shape on the * overlay window by setting the whole screen to be an * output region. * * Note: there doesn't seem to be any real chance of that * because the X server will destroy the overlay window * when the last client using it exits. */ XFixesSetWindowShapeRegion (xdisplay, info->output, ShapeBounding, 0, 0, None); do_set_stage_input_region (screen, info->pending_input_region); if (info->pending_input_region != None) { XFixesDestroyRegion (xdisplay, info->pending_input_region); info->pending_input_region = None; } clutter_actor_show (info->overlay_group); clutter_actor_show (info->stage); }