dnd: Don't use transformed size to calculate parent scale when restoring
Some drag actor parents might change their width to 0 after the drag actor has been removed. If the drag is now canceled and the drag actor is animated to return to the current parent position and scale, this scale can not be determined and falls back to 1.0. This might be wrong and can result in the drag actor being too large/small at the end of the return animation. To avoid this calculate the scale of the parent by recursively calculating the product of its parents individual scales. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4017 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1790>
This commit is contained in:
parent
bad94ab350
commit
e7780623fe
15
js/ui/dnd.js
15
js/ui/dnd.js
@ -56,6 +56,15 @@ function _getEventHandlerActor() {
|
||||
return eventHandlerActor;
|
||||
}
|
||||
|
||||
function _getRealActorScale(actor) {
|
||||
let scale = 1.0;
|
||||
while (actor) {
|
||||
scale *= actor.scale_x;
|
||||
actor = actor.get_parent();
|
||||
}
|
||||
return scale;
|
||||
}
|
||||
|
||||
function addDragMonitor(monitor) {
|
||||
dragMonitors.push(monitor);
|
||||
}
|
||||
@ -659,11 +668,7 @@ var _Draggable = class _Draggable {
|
||||
// its parent, adjusting for the fact that the parent
|
||||
// may have been moved or scaled
|
||||
let [parentX, parentY] = this._dragOrigParent.get_transformed_position();
|
||||
let [parentWidth] = this._dragOrigParent.get_size();
|
||||
let [parentScaledWidth] = this._dragOrigParent.get_transformed_size();
|
||||
let parentScale = 1.0;
|
||||
if (parentWidth != 0)
|
||||
parentScale = parentScaledWidth / parentWidth;
|
||||
let parentScale = _getRealActorScale(this._dragOrigParent);
|
||||
|
||||
x = parentX + parentScale * this._dragOrigX;
|
||||
y = parentY + parentScale * this._dragOrigY;
|
||||
|
Loading…
Reference in New Issue
Block a user