diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h index 8935732ba..eb536284f 100644 --- a/src/compositor/compositor-private.h +++ b/src/compositor/compositor-private.h @@ -18,7 +18,8 @@ struct _MetaCompositorClass { GObjectClass parent_class; - void (* manage) (MetaCompositor *compositor); + gboolean (* manage) (MetaCompositor *compositor, + GError **error); void (* unmanage) (MetaCompositor *compositor); void (* pre_paint) (MetaCompositor *compositor); void (* post_paint) (MetaCompositor *compositor); @@ -26,6 +27,9 @@ struct _MetaCompositorClass MetaWindow *window); }; +gboolean meta_compositor_do_manage (MetaCompositor *compositor, + GError **error); + void meta_compositor_remove_window_actor (MetaCompositor *compositor, MetaWindowActor *window_actor); diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 111965797..5681d7478 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -550,8 +550,9 @@ meta_compositor_redirect_x11_windows (MetaCompositor *compositor) redirect_windows (display->x11_display); } -void -meta_compositor_manage (MetaCompositor *compositor) +gboolean +meta_compositor_do_manage (MetaCompositor *compositor, + GError **error) { MetaCompositorPrivate *priv = meta_compositor_get_instance_private (compositor); @@ -587,9 +588,21 @@ meta_compositor_manage (MetaCompositor *compositor) clutter_actor_add_child (priv->stage, priv->top_window_group); clutter_actor_add_child (priv->stage, priv->feedback_group); - META_COMPOSITOR_GET_CLASS (compositor)->manage (compositor); + if (!META_COMPOSITOR_GET_CLASS (compositor)->manage (compositor, error)) + return FALSE; priv->plugin_mgr = meta_plugin_manager_new (compositor); + + return TRUE; +} + +void +meta_compositor_manage (MetaCompositor *compositor) +{ + GError *error = NULL; + + if (!meta_compositor_do_manage (compositor, &error)) + g_error ("Compositor failed to manage display: %s", error->message); } void diff --git a/src/compositor/meta-compositor-server.c b/src/compositor/meta-compositor-server.c index 928501f8a..361bcc599 100644 --- a/src/compositor/meta-compositor-server.c +++ b/src/compositor/meta-compositor-server.c @@ -29,9 +29,11 @@ struct _MetaCompositorServer G_DEFINE_TYPE (MetaCompositorServer, meta_compositor_server, META_TYPE_COMPOSITOR) -static void -meta_compositor_server_manage (MetaCompositor *compositor) +static gboolean +meta_compositor_server_manage (MetaCompositor *compositor, + GError **error) { + return TRUE; } static void diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c index 1737e97f5..211b907e9 100644 --- a/src/compositor/meta-compositor-x11.c +++ b/src/compositor/meta-compositor-x11.c @@ -100,15 +100,39 @@ meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11, meta_x11_handle_event (xevent); } -static void -meta_compositor_x11_manage (MetaCompositor *compositor) +static gboolean +meta_compositor_x11_manage (MetaCompositor *compositor, + GError **error) { MetaCompositorX11 *compositor_x11 = META_COMPOSITOR_X11 (compositor); MetaDisplay *display = meta_compositor_get_display (compositor); - Display *xdisplay = meta_x11_display_get_xdisplay (display->x11_display); + MetaX11Display *x11_display = display->x11_display; + Display *xdisplay = meta_x11_display_get_xdisplay (x11_display); + int composite_version; MetaBackend *backend = meta_get_backend (); Window xwindow; + if (!META_X11_DISPLAY_HAS_COMPOSITE (x11_display) || + !META_X11_DISPLAY_HAS_DAMAGE (x11_display)) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Missing required extension %s", + !META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ? + "composite" : "damage"); + return FALSE; + } + + composite_version = ((x11_display->composite_major_version * 10) + + x11_display->composite_minor_version); + if (composite_version < 3) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "COMPOSITE extension 3.0 required (found %d.%d)", + x11_display->composite_major_version, + x11_display->composite_minor_version); + return FALSE; + } + meta_x11_display_set_cm_selection (display->x11_display); compositor_x11->output = display->x11_display->composite_overlay_window; @@ -139,6 +163,8 @@ meta_compositor_x11_manage (MetaCompositor *compositor) compositor_x11->have_x11_sync_object = meta_sync_ring_init (xdisplay); meta_compositor_redirect_x11_windows (META_COMPOSITOR (compositor)); + + return TRUE; } static void diff --git a/src/core/display.c b/src/core/display.c index 0917f4693..8de64b0e0 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -579,39 +579,6 @@ create_compositor (MetaDisplay *display) return META_COMPOSITOR (meta_compositor_x11_new (display)); } -static void -enable_compositor (MetaDisplay *display) -{ - MetaX11Display *x11_display = display->x11_display; - - if (x11_display) - { - if (!META_X11_DISPLAY_HAS_COMPOSITE (x11_display) || - !META_X11_DISPLAY_HAS_DAMAGE (x11_display)) - { - meta_fatal ("Missing %s extension required for compositing", - !META_X11_DISPLAY_HAS_COMPOSITE (x11_display) ? - "composite" : "damage"); - return; - } - - int version = (x11_display->composite_major_version * 10) + - x11_display->composite_minor_version; - if (version < 3) - { - meta_fatal ("Your version of COMPOSITE (%d.%d) is too old. Version 3.0 or later required.", - x11_display->composite_major_version, - x11_display->composite_minor_version); - return; - } - } - - if (!display->compositor) - display->compositor = create_compositor (display); - - meta_compositor_manage (display->compositor); -} - static void meta_display_init (MetaDisplay *disp) { @@ -885,6 +852,8 @@ meta_display_open (void) g_signal_connect (settings, "ui-scaling-factor-changed", G_CALLBACK (on_ui_scaling_factor_changed), display); + display->compositor = create_compositor (display); + meta_display_set_cursor (display, META_CURSOR_DEFAULT); display->stack = meta_stack_new (display); @@ -922,7 +891,6 @@ meta_display_open (void) display->last_focus_time = timestamp; display->last_user_time = timestamp; - display->compositor = NULL; if (!meta_is_wayland_compositor ()) meta_prop_get_window (display->x11_display, @@ -930,7 +898,11 @@ meta_display_open (void) display->x11_display->atom__NET_ACTIVE_WINDOW, &old_active_xwindow); - enable_compositor (display); + if (!meta_compositor_do_manage (display->compositor, &error)) + { + g_error ("Compositor failed to manage display: %s", + error->message); + } if (display->x11_display) {