mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
clutter/actor: Inherit cloned painting when calculating resource scale
When calculating the resource scale of a clone source, we might end up in situations where we fail to do so, even though we're in a paint. A real world example when this may happen if this happens: * A client creates a toplevel window * A client creates a modal dialog for said toplevel window * Said client commits a buffer to the modal before the toplevel If GNOME Shell is in overview mode, the window group is hidden, and the toplevel window actor is hidden. When the clone tries to paint, it fails to calculate the resource scale, as the parent of the parent (window group) is not currently mapped. It would have succeeded if only the clone source was unmapped, as it deals with the unmapped actor painting by setting intermediate state while painting, but this does not work when the *parent* of the source is unmapped as well. Fix this by inheriting the unmapped clone paint even when calculating the resource scale. This also adds a test case that mimics the sequence of events otherwise triggered by a client. We can't add a Wayland client to test this, where we actually crash is in the offscreen redirect effect used by the window dimming feature in GNOME Shell. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/808 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1147
This commit is contained in:
parent
40c345d6f3
commit
32c99513c8
@ -17715,10 +17715,42 @@ _clutter_actor_compute_resource_scale (ClutterActor *self,
|
||||
resource_scale))
|
||||
{
|
||||
if (priv->parent)
|
||||
return _clutter_actor_compute_resource_scale (priv->parent,
|
||||
resource_scale);
|
||||
{
|
||||
gboolean in_clone_paint;
|
||||
gboolean was_parent_in_clone_paint;
|
||||
gboolean was_parent_unmapped;
|
||||
gboolean was_parent_paint_unmapped;
|
||||
gboolean ret;
|
||||
|
||||
in_clone_paint = clutter_actor_is_in_clone_paint (self);
|
||||
was_parent_unmapped = !clutter_actor_is_mapped (priv->parent);
|
||||
was_parent_in_clone_paint =
|
||||
clutter_actor_is_in_clone_paint (priv->parent);
|
||||
was_parent_paint_unmapped = priv->parent->priv->enable_paint_unmapped;
|
||||
|
||||
if (in_clone_paint && was_parent_unmapped)
|
||||
{
|
||||
_clutter_actor_set_in_clone_paint (priv->parent, TRUE);
|
||||
_clutter_actor_set_enable_paint_unmapped (priv->parent, TRUE);
|
||||
}
|
||||
|
||||
ret = _clutter_actor_compute_resource_scale (priv->parent,
|
||||
resource_scale);
|
||||
|
||||
if (in_clone_paint && was_parent_unmapped)
|
||||
{
|
||||
_clutter_actor_set_in_clone_paint (priv->parent,
|
||||
was_parent_in_clone_paint);
|
||||
_clutter_actor_set_enable_paint_unmapped (priv->parent,
|
||||
was_parent_paint_unmapped);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
68
src/tests/clutter/conform/actor-clone.c
Normal file
68
src/tests/clutter/conform/actor-clone.c
Normal file
@ -0,0 +1,68 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "tests/clutter-test-utils.h"
|
||||
|
||||
static void
|
||||
on_presented (ClutterStage *stage,
|
||||
CoglFrameEvent *frame_event,
|
||||
ClutterFrameInfo *frame_info,
|
||||
gboolean *was_presented)
|
||||
{
|
||||
*was_presented = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
actor_clone_unmapped (void)
|
||||
{
|
||||
ClutterActor *container;
|
||||
ClutterActor *actor;
|
||||
ClutterActor *clone;
|
||||
ClutterActor *stage;
|
||||
gboolean was_presented;
|
||||
|
||||
stage = clutter_test_get_stage ();
|
||||
|
||||
container = clutter_actor_new ();
|
||||
g_object_ref_sink (container);
|
||||
g_object_add_weak_pointer (G_OBJECT (container), (gpointer *) &container);
|
||||
|
||||
actor = clutter_actor_new ();
|
||||
g_object_ref_sink (actor);
|
||||
g_object_add_weak_pointer (G_OBJECT (actor), (gpointer *) &actor);
|
||||
|
||||
clone = clutter_clone_new (actor);
|
||||
g_object_ref_sink (clone);
|
||||
g_object_add_weak_pointer (G_OBJECT (clone), (gpointer *) &clone);
|
||||
|
||||
clutter_actor_hide (container);
|
||||
clutter_actor_hide (actor);
|
||||
|
||||
clutter_actor_add_child (stage, container);
|
||||
clutter_actor_add_child (container, actor);
|
||||
clutter_actor_add_child (stage, clone);
|
||||
|
||||
clutter_actor_set_offscreen_redirect (actor, CLUTTER_OFFSCREEN_REDIRECT_ALWAYS);
|
||||
|
||||
g_signal_connect (stage, "presented", G_CALLBACK (on_presented),
|
||||
&was_presented);
|
||||
|
||||
clutter_actor_show (stage);
|
||||
|
||||
was_presented = FALSE;
|
||||
while (!was_presented)
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
clutter_actor_destroy (clone);
|
||||
clutter_actor_destroy (actor);
|
||||
clutter_actor_destroy (container);
|
||||
g_assert_null (clone);
|
||||
g_assert_null (actor);
|
||||
g_assert_null (container);
|
||||
}
|
||||
|
||||
CLUTTER_TEST_SUITE (
|
||||
CLUTTER_TEST_UNIT ("/actor/clone/unmapped", actor_clone_unmapped)
|
||||
)
|
@ -10,6 +10,7 @@ clutter_tests_conform_link_args = [
|
||||
|
||||
clutter_conform_tests_actor_tests = [
|
||||
'actor-anchors',
|
||||
'actor-clone',
|
||||
'actor-destroy',
|
||||
'actor-graph',
|
||||
'actor-invariants',
|
||||
|
Loading…
Reference in New Issue
Block a user