wayland/dnd-surface: Scale DnD-surface-actor content if necessary

Since the recent clutter-content work, legacy scaling (in contrast
to the new stage-view-scaling) only applies to surfaces that belong
to a window. This broke scaling of DnD surfaces.

As a workaround, apply the same scaling on DnD-surface-actors until
we use stage-view-scaling by default and can remove this again.

Also: small corrections of geometry calculation

https://gitlab.gnome.org/GNOME/mutter/merge_requests/780
This commit is contained in:
Robert Mader 2019-09-06 16:11:03 +02:00 committed by Jonas Ådahl
parent bba8f6c53e
commit 25c1a85384

View File

@ -29,6 +29,7 @@ struct _MetaWaylandSurfaceRoleDND
MetaWaylandActorSurface parent;
int32_t pending_offset_x;
int32_t pending_offset_y;
int geometry_scale;
};
G_DEFINE_TYPE (MetaWaylandSurfaceRoleDND,
@ -106,29 +107,29 @@ dnd_subsurface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
META_WAYLAND_SURFACE_ROLE (actor_surface);
MetaWaylandSurfaceRoleDND *surface_role_dnd =
META_WAYLAND_SURFACE_ROLE_DND (surface_role);
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
MetaWaylandActorSurfaceClass *actor_surface_class =
META_WAYLAND_ACTOR_SURFACE_CLASS (meta_wayland_surface_role_dnd_parent_class);
float geometry_scale;
float actor_scale;
int geometry_scale;
float anchor_x;
float anchor_y;
float new_anchor_x;
float new_anchor_y;
g_return_if_fail (META_IS_FEEDBACK_ACTOR (feedback_actor));
geometry_scale =
meta_wayland_actor_surface_get_geometry_scale (actor_surface);
actor_scale = geometry_scale / surface->scale;
meta_feedback_actor_get_anchor (feedback_actor, &anchor_x, &anchor_y);
new_anchor_x = anchor_x - surface_role_dnd->pending_offset_x / actor_scale;
new_anchor_y = anchor_y - surface_role_dnd->pending_offset_y / actor_scale;
meta_feedback_actor_set_anchor (feedback_actor,
new_anchor_x,
new_anchor_y);
anchor_x -= surface_role_dnd->pending_offset_x * geometry_scale;
anchor_y -= surface_role_dnd->pending_offset_y * geometry_scale;
meta_feedback_actor_set_anchor (feedback_actor, anchor_x, anchor_y);
if (surface_role_dnd->geometry_scale != geometry_scale)
{
surface_role_dnd->geometry_scale = geometry_scale;
clutter_actor_set_scale (CLUTTER_ACTOR (surface_actor),
geometry_scale,
geometry_scale);
}
actor_surface_class->sync_actor_state (actor_surface);
}
@ -136,6 +137,7 @@ dnd_subsurface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
static void
meta_wayland_surface_role_dnd_init (MetaWaylandSurfaceRoleDND *role)
{
role->geometry_scale = 1;
}
static void