mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
display: Initialize MetaCompositor in two steps
MetaCompositor is the place in mutter that manages the higher level state of compositing, such as handling what happens before and after paint. In order for other units that depend on having a compositor instance active, but should be initialized before the X11 implementation of MetaCompositor registers as a X11 compositing manager, split the initialization of compositing into two steps: 1) Instantiate the object - only construct the instance, making it possible for users to start listening to signals etc 2) Manage - this e.g. establishes the compositor as the X11 compositing manager and similar things. This will enable us to put compositing dependent scattered global variables into a MetaCompositor owned object. For now, compositor management is internally done by calling a new `meta_compositor_do_manage()`, as right now we can't change the API of `meta_compositor_manage()` as it is public. For the next version, manual management of compositing will removed from the public API, and only managed internally. https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
This commit is contained in:
parent
d682cdb078
commit
dc4fe780f7
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user