compositor: Introduce MetaCompositorView
MetaCompositorView is a class which contains compositor logic specific to ClutterStageViews. Each MetaCompositorView is "attached" to a ClutterStageView as an opaque pointer using g_object_set_qdata_full (), and is freed when the ClutterStageView is destroyed. This ensures that the lifetime of the MetaCompositorView can't extend beyond the lifetime of its ClutterStageView. In a following commit, MetaCompositorView will be expanded to allow keeping track of the top MetaWindowActor located on each ClutterStageView. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2526>
This commit is contained in:
parent
1f7527bbc4
commit
049db7c7e5
@ -61,6 +61,7 @@
|
||||
#include "backends/x11/meta-stage-x11.h"
|
||||
#include "clutter/clutter-mutter.h"
|
||||
#include "cogl/cogl.h"
|
||||
#include "compositor/meta-compositor-view.h"
|
||||
#include "compositor/meta-later-private.h"
|
||||
#include "compositor/meta-window-actor-x11.h"
|
||||
#include "compositor/meta-window-actor-private.h"
|
||||
@ -108,6 +109,7 @@ typedef struct _MetaCompositorPrivate
|
||||
gulong before_paint_handler_id;
|
||||
gulong after_paint_handler_id;
|
||||
gulong window_visibility_updated_id;
|
||||
gulong monitors_changed_internal_id;
|
||||
|
||||
int64_t server_time_query_time;
|
||||
int64_t server_time_offset;
|
||||
@ -137,6 +139,8 @@ typedef struct _MetaCompositorPrivate
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaCompositor, meta_compositor,
|
||||
G_TYPE_OBJECT)
|
||||
|
||||
static GQuark quark_compositor_view;
|
||||
|
||||
static void
|
||||
on_presented (ClutterStage *stage,
|
||||
ClutterStageView *stage_view,
|
||||
@ -926,6 +930,35 @@ meta_compositor_sync_window_geometry (MetaCompositor *compositor,
|
||||
meta_plugin_manager_event_size_changed (priv->plugin_mgr, window_actor);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_ensure_compositor_views (MetaCompositor *compositor)
|
||||
{
|
||||
MetaCompositorPrivate *priv =
|
||||
meta_compositor_get_instance_private (compositor);
|
||||
ClutterStage *stage =
|
||||
CLUTTER_STAGE (meta_backend_get_stage (priv->backend));
|
||||
GList *l;
|
||||
|
||||
for (l = clutter_stage_peek_stage_views (stage); l; l = l->next)
|
||||
{
|
||||
ClutterStageView *stage_view = l->data;
|
||||
MetaCompositorView *compositor_view;
|
||||
|
||||
compositor_view = g_object_get_qdata (G_OBJECT (stage_view),
|
||||
quark_compositor_view);
|
||||
|
||||
if (compositor_view)
|
||||
continue;
|
||||
|
||||
compositor_view = meta_compositor_view_new (stage_view);
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (stage_view),
|
||||
quark_compositor_view,
|
||||
compositor_view,
|
||||
g_object_unref);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_presented (ClutterStage *stage,
|
||||
ClutterStageView *stage_view,
|
||||
@ -1053,6 +1086,13 @@ on_window_visibility_updated (MetaDisplay *display,
|
||||
update_top_window_actor (compositor);
|
||||
}
|
||||
|
||||
static void
|
||||
on_monitors_changed_internal (MetaMonitorManager *monitor_manager,
|
||||
MetaCompositor *compositor)
|
||||
{
|
||||
meta_compositor_ensure_compositor_views (compositor);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -1113,6 +1153,8 @@ meta_compositor_constructed (GObject *object)
|
||||
ClutterBackend *clutter_backend =
|
||||
meta_backend_get_clutter_backend (priv->backend);
|
||||
ClutterActor *stage = meta_backend_get_stage (priv->backend);
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (priv->backend);
|
||||
|
||||
priv->context = clutter_backend->cogl_context;
|
||||
|
||||
@ -1133,9 +1175,17 @@ meta_compositor_constructed (GObject *object)
|
||||
G_CALLBACK (on_window_visibility_updated),
|
||||
compositor);
|
||||
|
||||
priv->monitors_changed_internal_id =
|
||||
g_signal_connect (monitor_manager,
|
||||
"monitors-changed-internal",
|
||||
G_CALLBACK (on_monitors_changed_internal),
|
||||
compositor);
|
||||
|
||||
priv->laters = meta_laters_new (compositor);
|
||||
|
||||
G_OBJECT_CLASS (meta_compositor_parent_class)->constructed (object);
|
||||
|
||||
meta_compositor_ensure_compositor_views (compositor);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1190,6 +1240,9 @@ meta_compositor_class_init (MetaCompositorClass *klass)
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
||||
|
||||
quark_compositor_view =
|
||||
g_quark_from_static_string ("-meta-compositor-view");
|
||||
}
|
||||
|
||||
/**
|
||||
|
129
src/compositor/meta-compositor-view.c
Normal file
129
src/compositor/meta-compositor-view.c
Normal file
@ -0,0 +1,129 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Dor Askayo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Dor Askayo <dor.askayo@gmail.com>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "compositor/meta-compositor-view.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_STAGE_VIEW,
|
||||
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[N_PROPS];
|
||||
|
||||
typedef struct _MetaCompositorViewPrivate
|
||||
{
|
||||
ClutterStageView *stage_view;
|
||||
} MetaCompositorViewPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (MetaCompositorView, meta_compositor_view,
|
||||
G_TYPE_OBJECT)
|
||||
|
||||
MetaCompositorView *
|
||||
meta_compositor_view_new (ClutterStageView *stage_view)
|
||||
{
|
||||
g_assert (stage_view);
|
||||
|
||||
return g_object_new (META_TYPE_COMPOSITOR_VIEW,
|
||||
"stage-view", stage_view,
|
||||
NULL);
|
||||
}
|
||||
|
||||
ClutterStageView *
|
||||
meta_compositor_view_get_stage_view (MetaCompositorView *compositor_view)
|
||||
{
|
||||
MetaCompositorViewPrivate *priv =
|
||||
meta_compositor_view_get_instance_private (compositor_view);
|
||||
|
||||
return priv->stage_view;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_view_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaCompositorView *compositor_view = META_COMPOSITOR_VIEW (object);
|
||||
MetaCompositorViewPrivate *priv =
|
||||
meta_compositor_view_get_instance_private (compositor_view);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_STAGE_VIEW:
|
||||
priv->stage_view = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_view_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaCompositorView *compositor_view = META_COMPOSITOR_VIEW (object);
|
||||
MetaCompositorViewPrivate *priv =
|
||||
meta_compositor_view_get_instance_private (compositor_view);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_STAGE_VIEW:
|
||||
g_value_set_object (value, priv->stage_view);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_view_class_init (MetaCompositorViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = meta_compositor_view_set_property;
|
||||
object_class->get_property = meta_compositor_view_get_property;
|
||||
|
||||
obj_props[PROP_STAGE_VIEW] =
|
||||
g_param_spec_object ("stage-view",
|
||||
"stage-view",
|
||||
"ClutterStageView",
|
||||
CLUTTER_TYPE_STAGE_VIEW,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_compositor_view_init (MetaCompositorView *compositor_view)
|
||||
{
|
||||
}
|
45
src/compositor/meta-compositor-view.h
Normal file
45
src/compositor/meta-compositor-view.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Dor Askayo
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Written by:
|
||||
* Dor Askayo <dor.askayo@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef META_COMPOSITOR_VIEW_H
|
||||
#define META_COMPOSITOR_VIEW_H
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "clutter/clutter-mutter.h"
|
||||
|
||||
struct _MetaCompositorViewClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
#define META_TYPE_COMPOSITOR_VIEW (meta_compositor_view_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (MetaCompositorView, meta_compositor_view,
|
||||
META, COMPOSITOR_VIEW, GObject)
|
||||
|
||||
MetaCompositorView *meta_compositor_view_new (ClutterStageView *stage_view);
|
||||
|
||||
ClutterStageView *meta_compositor_view_get_stage_view (MetaCompositorView *compositor_view);
|
||||
|
||||
#endif /* META_COMPOSITOR_VIEW_H */
|
@ -268,6 +268,8 @@ mutter_sources = [
|
||||
'compositor/meta-background-private.h',
|
||||
'compositor/meta-compositor-server.c',
|
||||
'compositor/meta-compositor-server.h',
|
||||
'compositor/meta-compositor-view.c',
|
||||
'compositor/meta-compositor-view.h',
|
||||
'compositor/meta-cullable.c',
|
||||
'compositor/meta-cullable.h',
|
||||
'compositor/meta-dnd-actor.c',
|
||||
|
Loading…
x
Reference in New Issue
Block a user