After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 787901 - DnD: Prevent dividing by zero when calculating the scale factor
DnD: Prevent dividing by zero when calculating the scale factor
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2017-09-19 15:26 UTC by Mario Sánchez Prada
Modified: 2017-09-22 14:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
dnd: Prevent dividing by zero when calculating the scale factor (1.17 KB, patch)
2017-09-19 15:28 UTC, Mario Sánchez Prada
none Details | Review
dnd: Prevent dividing by zero when calculating the scale factor (1.52 KB, patch)
2017-09-22 12:48 UTC, Mario Sánchez Prada
needs-work Details | Review

Description Mario Sánchez Prada 2017-09-19 15:26:47 UTC
Probably not a big issue on the shell upstream but on Endless, where DnD is really visible as it's supported on the desktop itself, I've observed lots of warnings when DnD'ing icons around due to having clutter_actor_get_transformed_size() return zero widths for the dragActorSource.

Thus, it would be nice to have a zero-check before using that value as the denominator in getRestoreLocation().

From a patch we currently carry around on Endless downstream:
https://github.com/endlessm/gnome-shell/commit/856b52c909be654ac2e7660ffb5013857846e857
Comment 1 Mario Sánchez Prada 2017-09-19 15:28:11 UTC
Created attachment 360051 [details] [review]
dnd: Prevent dividing by zero when calculating the scale factor

Patch attached
Comment 2 Florian Müllner 2017-09-21 17:24:56 UTC
Review of attachment 360051 [details] [review]:

::: js/ui/dnd.js
@@ +531,3 @@
             [x, y] = this._dragActorSource.get_transformed_position();
             let [sourceScaledWidth, sourceScaledHeight] = this._dragActorSource.get_transformed_size();
+            scale = sourceScaledWidth ? this._dragActor.width / sourceScaledWidth : 1;

This looks wrong - if the source actor has been scaled to 0, then I think it makes more sense to shrink the drag actor to 0 when snapping back rather than keeping it unscaled and disappear abruptly at the end of the transition.
Comment 3 Mario Sánchez Prada 2017-09-22 12:42:47 UTC
Good point, that works better indeed
Comment 4 Mario Sánchez Prada 2017-09-22 12:48:39 UTC
Created attachment 360256 [details] [review]
dnd: Prevent dividing by zero when calculating the scale factor
Comment 5 Florian Müllner 2017-09-22 12:55:29 UTC
Review of attachment 360256 [details] [review]:

There's an accidental submodule update in the patch, otherwise LGTM.

The commit message could be better though - "moving icons aroung(sic!) the desktop" doesn't actually apply to upstream. Something like:

This ensures that we snap back to the correct size when the
source actor has been scaled to 0.
Comment 6 Mario Sánchez Prada 2017-09-22 14:51:54 UTC
(In reply to Florian Müllner from comment #5)
> Review of attachment 360256 [details] [review] [review]:
> 
> There's an accidental submodule update in the patch, otherwise LGTM.
> 
> The commit message could be better though - "moving icons aroung(sic!) the
> desktop" doesn't actually apply to upstream. Something like:
> 
> This ensures that we snap back to the correct size when the
> source actor has been scaled to 0.

Oops! Fixed those minor issues and pushed to master:
https://git.gnome.org/browse/gnome-shell/commit/?id=703187e99620de085978954fe3a3004676de1046