Skip to content

Commit

Permalink
wayland: Fix desktop background
Browse files Browse the repository at this point in the history
- Disable X11BackgroundActor in wayland
- wayland compositor: Identify background windows created by
csd-background and stack them correctly in the bottom_window_group.
  • Loading branch information
mtwebster authored and clefebvre committed Nov 7, 2023
1 parent bc10efe commit 4b87bf9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 33 deletions.
44 changes: 39 additions & 5 deletions src/compositor/compositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,15 +600,19 @@ meta_compositor_manage (MetaCompositor *compositor)
priv->top_window_group = meta_window_group_new (display);
priv->bottom_window_group = meta_window_group_new (display);
priv->feedback_group = meta_window_group_new (display);
priv->background_actor = meta_x11_background_actor_new_for_display (display);

if (!meta_is_wayland_compositor ())
{
priv->background_actor = meta_x11_background_actor_new_for_display (display);
clutter_actor_add_child (priv->window_group, priv->background_actor);
}

clutter_actor_add_child (priv->window_group, priv->bottom_window_group);

// This needs to remain stacked just above the background actor in the window group.
// So sync_actor_stacking() has to be able to reference it. The deskletManager
// will take this and finish setting it up.
priv->desklet_container = clutter_actor_new ();

clutter_actor_add_child (priv->window_group, priv->background_actor);
clutter_actor_add_child (priv->window_group, priv->bottom_window_group);
clutter_actor_add_child (priv->window_group, priv->desklet_container);
clutter_actor_add_child (priv->stage, priv->window_group);
clutter_actor_add_child (priv->stage, priv->top_window_group);
Expand Down Expand Up @@ -954,7 +958,7 @@ sync_actor_stacking (MetaCompositor *compositor)
}
}

g_list_free (children);
g_clear_pointer (&children, g_list_free);

if (!reordered)
{
Expand Down Expand Up @@ -989,6 +993,31 @@ sync_actor_stacking (MetaCompositor *compositor)
// Then the bottom window group (which META_WINDOW_DESKTOP windows like nemo-desktop's get placed in).
clutter_actor_set_child_below_sibling (priv->window_group, priv->bottom_window_group, NULL);

if (meta_is_wayland_compositor ())
{
children = clutter_actor_get_children (priv->bottom_window_group);
for (tmp = children; tmp != NULL; tmp = tmp->next)
{
MetaWindowActor *child = tmp->data;
MetaWindow *mw = meta_window_actor_get_meta_window (child);

if (mw != NULL)
{
// CsdBackground manager sets _NET_WM_STATE_BELOW (gtk_window_set_keep_below)
// This sets its stack layer to META_LAYER_BOTTOM, so we can keep these below
// the nemo-desktop, etc..
MetaStackLayer layer = meta_window_get_default_layer (mw);

if (layer == META_LAYER_BOTTOM)
{
clutter_actor_set_child_below_sibling (priv->bottom_window_group, CLUTTER_ACTOR (child), NULL);
}
}
}

g_list_free (children);
}

// and finally backgrounds..

/* we prepended the backgrounds above so the last actor in the list
Expand Down Expand Up @@ -1719,6 +1748,11 @@ meta_get_x11_background_actor_for_display (MetaDisplay *display)
MetaCompositorPrivate *priv =
meta_compositor_get_instance_private (display->compositor);

if (meta_is_wayland_compositor ())
{
return NULL;
}

return priv->background_actor;
}

Expand Down
31 changes: 3 additions & 28 deletions src/x11/meta-x11-background-actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ meta_x11_background_actor_new_for_display (MetaDisplay *display)

g_return_val_if_fail (META_IS_DISPLAY (display), NULL);

if (meta_is_wayland_compositor ())
return NULL;

self = g_object_new (META_TYPE_X11_BACKGROUND_ACTOR, NULL);
priv = self->priv;

Expand Down Expand Up @@ -567,7 +570,6 @@ meta_x11_background_actor_update (MetaDisplay *display)
{
MetaX11Display *x11_display;
MetaDisplayBackground *background;
MetaCompositor *compositor;
Atom type;
int format;
gulong nitems;
Expand All @@ -577,7 +579,6 @@ meta_x11_background_actor_update (MetaDisplay *display)

x11_display = meta_display_get_x11_display (display);
background = meta_display_background_get (display);
compositor = meta_display_get_compositor (display);

root_pixmap_id = None;
if (!XGetWindowProperty (meta_x11_display_get_xdisplay (x11_display),
Expand Down Expand Up @@ -666,29 +667,3 @@ meta_x11_background_actor_screen_size_changed (MetaDisplay *x11_display)

update_wrap_mode (background);
}

static MetaDisplayBackground *
display_background_get (MetaDisplay *display)
{
MetaDisplayBackground *background;

background = g_object_get_data (G_OBJECT (display), "meta-display-background");
if (background == NULL)
{
ClutterActor *stage;

background = g_new0 (MetaDisplayBackground, 1);

background->x11_display = meta_display_get_x11_display (display);
g_object_set_data_full (G_OBJECT (display), "meta-screen-background",
background, (GDestroyNotify) free_display_background);

stage = meta_get_stage_for_display (display);
g_signal_connect (stage, "notify::background-color",
G_CALLBACK (on_notify_stage_color), background);

meta_x11_background_actor_update (display);
}

return background;
}

0 comments on commit 4b87bf9

Please sign in to comment.