compositor: Make type derivable

This is so that we can split it up properly into X11 compositor and
display server compositor sub types.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
This commit is contained in:
Jonas Ådahl 2019-08-14 19:04:41 +02:00 committed by Georges Basile Stavracas Neto
parent 55cd110c63
commit 12ea2fcb51
10 changed files with 402 additions and 198 deletions

View File

@ -335,7 +335,10 @@ handle_host_xevent (MetaBackend *backend,
if (display) if (display)
{ {
MetaCompositor *compositor = display->compositor; MetaCompositor *compositor = display->compositor;
if (meta_plugin_manager_xevent_filter (compositor->plugin_mgr, event)) MetaPluginManager *plugin_mgr =
meta_compositor_get_plugin_manager (compositor);
if (meta_plugin_manager_xevent_filter (plugin_mgr, event))
bypass_clutter = TRUE; bypass_clutter = TRUE;
if (meta_dnd_handle_xdnd_event (backend, compositor, priv->xdisplay, event)) if (meta_dnd_handle_xdnd_event (backend, compositor, priv->xdisplay, event))

View File

@ -11,47 +11,17 @@
#include "meta/compositor.h" #include "meta/compositor.h"
#include "meta/display.h" #include "meta/display.h"
struct _MetaCompositor
{
GObject parent;
MetaDisplay *display;
guint pre_paint_func_id;
guint post_paint_func_id;
gulong stage_presented_id;
gulong stage_after_paint_id;
gint64 server_time_query_time;
gint64 server_time_offset;
guint server_time_is_monotonic_time : 1;
ClutterActor *stage, *window_group, *top_window_group, *feedback_group;
GList *windows;
Window output;
CoglContext *context;
MetaWindowActor *top_window_actor;
gulong top_window_actor_destroy_id;
/* Used for unredirecting fullscreen windows */
guint disable_unredirect_count;
MetaWindow *unredirected_window;
gint switch_workspace_in_progress;
MetaPluginManager *plugin_mgr;
gboolean frame_has_updated_xsurfaces;
gboolean have_x11_sync_object;
};
/* Wait 2ms after vblank before starting to draw next frame */ /* Wait 2ms after vblank before starting to draw next frame */
#define META_SYNC_DELAY 2 #define META_SYNC_DELAY 2
struct _MetaCompositorClass
{
GObjectClass parent_class;
};
void meta_compositor_remove_window_actor (MetaCompositor *compositor,
MetaWindowActor *window_actor);
void meta_switch_workspace_completed (MetaCompositor *compositor); void meta_switch_workspace_completed (MetaCompositor *compositor);
gboolean meta_begin_modal_for_plugin (MetaCompositor *compositor, gboolean meta_begin_modal_for_plugin (MetaCompositor *compositor,
@ -62,6 +32,8 @@ void meta_end_modal_for_plugin (MetaCompositor *compositor,
MetaPlugin *plugin, MetaPlugin *plugin,
guint32 timestamp); guint32 timestamp);
MetaPluginManager * meta_compositor_get_plugin_manager (MetaCompositor *compositor);
gint64 meta_compositor_monotonic_time_to_server_time (MetaDisplay *display, gint64 meta_compositor_monotonic_time_to_server_time (MetaDisplay *display,
gint64 monotonic_time); gint64 monotonic_time);
@ -78,4 +50,12 @@ void meta_compositor_locate_pointer (MetaCompositor *compositor);
void meta_compositor_redirect_x11_windows (MetaCompositor *compositor); void meta_compositor_redirect_x11_windows (MetaCompositor *compositor);
MetaDisplay * meta_compositor_get_display (MetaCompositor *compositor);
Window meta_compositor_get_output_xwindow (MetaCompositor *compositor);
ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor);
gboolean meta_compositor_is_switching_workspace (MetaCompositor *compositor);
#endif /* META_COMPOSITOR_PRIVATE_H */ #endif /* META_COMPOSITOR_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@ -174,13 +174,16 @@ meta_dnd_handle_xdnd_event (MetaBackend *backend,
XEvent *xev) XEvent *xev)
{ {
MetaDnd *dnd = meta_backend_get_dnd (backend); MetaDnd *dnd = meta_backend_get_dnd (backend);
Window output_window = compositor->output; Window output_window;
ClutterStage *stage;
if (xev->xany.type != ClientMessage) if (xev->xany.type != ClientMessage)
return FALSE; return FALSE;
output_window = meta_compositor_get_output_xwindow (compositor);
stage = meta_compositor_get_stage (compositor);
if (xev->xany.window != output_window && if (xev->xany.window != output_window &&
xev->xany.window != clutter_x11_get_stage_window (CLUTTER_STAGE (compositor->stage))) xev->xany.window != clutter_x11_get_stage_window (stage))
return FALSE; return FALSE;
if (xev->xclient.message_type == XInternAtom (xdisplay, "XdndPosition", TRUE)) if (xev->xclient.message_type == XInternAtom (xdisplay, "XdndPosition", TRUE))
@ -285,20 +288,22 @@ meta_dnd_wayland_handle_begin_modal (MetaCompositor *compositor)
if (priv->handler_id[0] == 0 && if (priv->handler_id[0] == 0 &&
meta_wayland_data_device_get_current_grab (&wl_compositor->seat->data_device) != NULL) meta_wayland_data_device_get_current_grab (&wl_compositor->seat->data_device) != NULL)
{ {
ClutterStage *stage = meta_compositor_get_stage (compositor);
priv->compositor = compositor; priv->compositor = compositor;
priv->wl_compositor = wl_compositor; priv->wl_compositor = wl_compositor;
priv->handler_id[0] = g_signal_connect (compositor->stage, priv->handler_id[0] = g_signal_connect (stage,
"motion-event", "motion-event",
G_CALLBACK (meta_dnd_wayland_on_motion_event), G_CALLBACK (meta_dnd_wayland_on_motion_event),
dnd); dnd);
priv->handler_id[1] = g_signal_connect (compositor->stage, priv->handler_id[1] = g_signal_connect (stage,
"button-release-event", "button-release-event",
G_CALLBACK (meta_dnd_wayland_on_button_released), G_CALLBACK (meta_dnd_wayland_on_button_released),
dnd); dnd);
priv->handler_id[2] = g_signal_connect (compositor->stage, priv->handler_id[2] = g_signal_connect (stage,
"key-press-event", "key-press-event",
G_CALLBACK (meta_dnd_wayland_on_key_pressed), G_CALLBACK (meta_dnd_wayland_on_key_pressed),
dnd); dnd);
@ -312,6 +317,7 @@ meta_dnd_wayland_handle_end_modal (MetaCompositor *compositor)
{ {
MetaDnd *dnd = meta_backend_get_dnd (meta_get_backend ()); MetaDnd *dnd = meta_backend_get_dnd (meta_get_backend ());
MetaDndPrivate *priv = meta_dnd_get_instance_private (dnd); MetaDndPrivate *priv = meta_dnd_get_instance_private (dnd);
ClutterStage *stage = meta_compositor_get_stage (compositor);
unsigned int i; unsigned int i;
if (!priv->compositor) if (!priv->compositor)
@ -319,7 +325,7 @@ meta_dnd_wayland_handle_end_modal (MetaCompositor *compositor)
for (i = 0; i < G_N_ELEMENTS (priv->handler_id); i++) for (i = 0; i < G_N_ELEMENTS (priv->handler_id); i++)
{ {
g_signal_handler_disconnect (priv->compositor->stage, priv->handler_id[i]); g_signal_handler_disconnect (stage, priv->handler_id[i]);
priv->handler_id[i] = 0; priv->handler_id[i] = 0;
} }

View File

@ -52,10 +52,11 @@ static void
meta_feedback_actor_constructed (GObject *object) meta_feedback_actor_constructed (GObject *object)
{ {
MetaDisplay *display; MetaDisplay *display;
ClutterActor *feedback_group;
display = meta_get_display (); display = meta_get_display ();
clutter_actor_add_child (display->compositor->feedback_group, feedback_group = meta_get_feedback_group_for_display (display);
CLUTTER_ACTOR (object)); clutter_actor_add_child (feedback_group, CLUTTER_ACTOR (object));
} }
static void static void

View File

@ -156,7 +156,7 @@ meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr,
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
gboolean retval = FALSE; gboolean retval = FALSE;
if (display->display_opening) if (display->display_opening)
@ -225,7 +225,7 @@ meta_plugin_manager_event_size_change (MetaPluginManager *plugin_mgr,
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
if (display->display_opening) if (display->display_opening)
return FALSE; return FALSE;
@ -254,7 +254,7 @@ meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr,
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
gboolean retval = FALSE; gboolean retval = FALSE;
if (display->display_opening) if (display->display_opening)
@ -312,7 +312,7 @@ meta_plugin_manager_show_tile_preview (MetaPluginManager *plugin_mgr,
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
if (display->display_opening) if (display->display_opening)
return FALSE; return FALSE;
@ -331,7 +331,7 @@ meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
if (display->display_opening) if (display->display_opening)
return FALSE; return FALSE;
@ -354,7 +354,7 @@ meta_plugin_manager_show_window_menu (MetaPluginManager *plugin_mgr,
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
if (display->display_opening) if (display->display_opening)
return; return;
@ -371,7 +371,7 @@ meta_plugin_manager_show_window_menu_for_rect (MetaPluginManager *plugin_mgr,
{ {
MetaPlugin *plugin = plugin_mgr->plugin; MetaPlugin *plugin = plugin_mgr->plugin;
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
MetaDisplay *display = plugin_mgr->compositor->display; MetaDisplay *display = meta_compositor_get_display (plugin_mgr->compositor);
if (display->display_opening) if (display->display_opening)
return; return;

View File

@ -199,8 +199,9 @@ MetaDisplay *
meta_plugin_get_display (MetaPlugin *plugin) meta_plugin_get_display (MetaPlugin *plugin)
{ {
MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin); MetaPluginPrivate *priv = meta_plugin_get_instance_private (plugin);
MetaDisplay *display = meta_compositor_get_display (priv->compositor);
return priv->compositor->display; return display;
} }
void void

View File

@ -272,7 +272,7 @@ assign_frame_counter_to_frames (MetaWindowActorX11 *actor_x11)
MetaWindow *window = MetaWindow *window =
meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11)); meta_window_actor_get_meta_window (META_WINDOW_ACTOR (actor_x11));
MetaCompositor *compositor = window->display->compositor; MetaCompositor *compositor = window->display->compositor;
ClutterStage *stage = CLUTTER_STAGE (compositor->stage); ClutterStage *stage = meta_compositor_get_stage (compositor);
GList *l; GList *l;
/* If the window is obscured, then we're expecting to deal with sending /* If the window is obscured, then we're expecting to deal with sending

View File

@ -465,7 +465,7 @@ meta_window_actor_dispose (GObject *object)
g_clear_pointer (&priv->unfocused_shadow, meta_shadow_unref); g_clear_pointer (&priv->unfocused_shadow, meta_shadow_unref);
g_clear_pointer (&priv->shadow_shape, meta_window_shape_unref); g_clear_pointer (&priv->shadow_shape, meta_window_shape_unref);
compositor->windows = g_list_remove (compositor->windows, (gconstpointer) self); meta_compositor_remove_window_actor (compositor, self);
g_clear_object (&priv->window); g_clear_object (&priv->window);
@ -921,10 +921,12 @@ start_simple_effect (MetaWindowActor *self,
MetaWindowActorPrivate *priv = MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (self); meta_window_actor_get_instance_private (self);
MetaCompositor *compositor = priv->compositor; MetaCompositor *compositor = priv->compositor;
MetaPluginManager *plugin_mgr =
meta_compositor_get_plugin_manager (compositor);
gint *counter = NULL; gint *counter = NULL;
gboolean use_freeze_thaw = FALSE; gboolean use_freeze_thaw = FALSE;
g_assert (compositor->plugin_mgr != NULL); g_assert (plugin_mgr != NULL);
switch (event) switch (event)
{ {
@ -957,7 +959,7 @@ start_simple_effect (MetaWindowActor *self,
(*counter)++; (*counter)++;
if (!meta_plugin_manager_event_simple (compositor->plugin_mgr, self, event)) if (!meta_plugin_manager_event_simple (plugin_mgr, self, event))
{ {
(*counter)--; (*counter)--;
if (use_freeze_thaw) if (use_freeze_thaw)
@ -1216,7 +1218,7 @@ meta_window_actor_show (MetaWindowActor *self,
g_assert_not_reached(); g_assert_not_reached();
} }
if (compositor->switch_workspace_in_progress || if (meta_compositor_is_switching_workspace (compositor) ||
!start_simple_effect (self, event)) !start_simple_effect (self, event))
{ {
clutter_actor_show (CLUTTER_ACTOR (self)); clutter_actor_show (CLUTTER_ACTOR (self));
@ -1240,7 +1242,7 @@ meta_window_actor_hide (MetaWindowActor *self,
* hold off on hiding the window, and do it after the workspace * hold off on hiding the window, and do it after the workspace
* switch completes * switch completes
*/ */
if (compositor->switch_workspace_in_progress) if (meta_compositor_is_switching_workspace (compositor))
return; return;
switch (effect) switch (effect)
@ -1271,11 +1273,13 @@ meta_window_actor_size_change (MetaWindowActor *self,
MetaWindowActorPrivate *priv = MetaWindowActorPrivate *priv =
meta_window_actor_get_instance_private (self); meta_window_actor_get_instance_private (self);
MetaCompositor *compositor = priv->compositor; MetaCompositor *compositor = priv->compositor;
MetaPluginManager *plugin_mgr =
meta_compositor_get_plugin_manager (compositor);
priv->size_change_in_progress++; priv->size_change_in_progress++;
meta_window_actor_freeze (self); meta_window_actor_freeze (self);
if (!meta_plugin_manager_event_size_change (compositor->plugin_mgr, self, if (!meta_plugin_manager_event_size_change (plugin_mgr, self,
which_change, old_frame_rect, old_buffer_rect)) which_change, old_frame_rect, old_buffer_rect))
{ {
priv->size_change_in_progress--; priv->size_change_in_progress--;

View File

@ -30,7 +30,8 @@
#define META_TYPE_COMPOSITOR (meta_compositor_get_type ()) #define META_TYPE_COMPOSITOR (meta_compositor_get_type ())
META_EXPORT META_EXPORT
G_DECLARE_FINAL_TYPE (MetaCompositor, meta_compositor, META, COMPOSITOR, GObject) G_DECLARE_DERIVABLE_TYPE (MetaCompositor, meta_compositor,
META, COMPOSITOR, GObject)
/** /**
* MetaCompEffect: * MetaCompEffect: