[mutter] window-actor: Add 'damaged' signal
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] window-actor: Add 'damaged' signal
- Date: Tue, 27 Aug 2019 15:38:42 +0000 (UTC)
commit ad138210b3ef57dce7260ddc741527235c8e6f6c
Author: Jonas Ådahl <jadahl gmail com>
Date: Mon Aug 26 16:09:53 2019 +0300
window-actor: Add 'damaged' signal
Make it possible to listen for damage on a window actor. For X11, the
signal is emitted when damage is reported; for Wayland, it is emitted
when any of the surfaces associated with the window is damaged.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/752
src/compositor/meta-window-actor-private.h | 2 ++
src/compositor/meta-window-actor.c | 23 +++++++++++++++++++++++
src/wayland/meta-wayland-surface.c | 27 ++++++++++++++++++++++++---
3 files changed, 49 insertions(+), 3 deletions(-)
---
diff --git a/src/compositor/meta-window-actor-private.h b/src/compositor/meta-window-actor-private.h
index 354edd314..a36217f98 100644
--- a/src/compositor/meta-window-actor-private.h
+++ b/src/compositor/meta-window-actor-private.h
@@ -93,4 +93,6 @@ void meta_window_actor_set_geometry_scale (MetaWindowActor *window_actor,
int meta_window_actor_get_geometry_scale (MetaWindowActor *window_actor);
+void meta_window_actor_notify_damaged (MetaWindowActor *window_actor);
+
#endif /* META_WINDOW_ACTOR_PRIVATE_H */
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index d2d46e6b0..f0df27666 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -115,6 +115,7 @@ enum
{
FIRST_FRAME,
EFFECTS_COMPLETED,
+ DAMAGED,
LAST_SIGNAL
};
@@ -219,6 +220,20 @@ meta_window_actor_class_init (MetaWindowActorClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 0);
+ /**
+ * MetaWindowActor::damaged:
+ * @actor: the #MetaWindowActor instance
+ *
+ * Notify that one or more of the surfaces of the window have been damaged.
+ */
+ signals[DAMAGED] =
+ g_signal_new ("damaged",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
pspec = g_param_spec_object ("meta-window",
"MetaWindow",
"The displayed MetaWindow",
@@ -1498,6 +1513,8 @@ meta_window_actor_process_x11_damage (MetaWindowActor *self,
event->area.y,
event->area.width,
event->area.height);
+
+ meta_window_actor_notify_damaged (self);
}
void
@@ -2111,3 +2128,9 @@ meta_window_actor_from_actor (ClutterActor *actor)
return NULL;
}
+
+void
+meta_window_actor_notify_damaged (MetaWindowActor *window_actor)
+{
+ g_signal_emit (window_actor, signals[DAMAGED], 0);
+}
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 9a1b45ece..12a607b47 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -672,6 +672,8 @@ void
meta_wayland_surface_apply_pending_state (MetaWaylandSurface *surface,
MetaWaylandPendingState *pending)
{
+ gboolean had_damage = FALSE;
+
if (surface->role)
{
meta_wayland_surface_role_pre_commit (surface->role, pending);
@@ -778,9 +780,12 @@ meta_wayland_surface_apply_pending_state (MetaWaylandSurface *surface,
if (!cairo_region_is_empty (pending->surface_damage) ||
!cairo_region_is_empty (pending->buffer_damage))
- surface_process_damage (surface,
- pending->surface_damage,
- pending->buffer_damage);
+ {
+ surface_process_damage (surface,
+ pending->surface_damage,
+ pending->buffer_damage);
+ had_damage = TRUE;
+ }
surface->offset_x += pending->dx;
surface->offset_y += pending->dy;
@@ -844,6 +849,22 @@ cleanup:
G_TRAVERSE_ALL,
parent_surface_state_applied,
NULL);
+
+ if (had_damage)
+ {
+ MetaWindow *toplevel_window;
+
+ toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
+ if (toplevel_window)
+ {
+ MetaWindowActor *toplevel_window_actor;
+
+ toplevel_window_actor =
+ meta_window_actor_from_window (toplevel_window);
+ if (toplevel_window_actor)
+ meta_window_actor_notify_damaged (toplevel_window_actor);
+ }
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]