Unity launcher appearing interrupts GTK drag and drop operation (that's nowhere near the launcher)

Bug #1018215 reported by Matthew Pirocchi
46
This bug affects 16 people
Affects Status Importance Assigned to Milestone
Unity
Triaged
Medium
Unassigned
unity (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

I am a developer for an app that uses Gtk's "drag-motion" and "drag-leave" signals. It is important that "drag-leave" not be fired until the mouse actually leaves the widget. However, when running unit, "drag-leave" will be fired ~1 second after a drag begins.

Here is a test project (in Vala) that reproduces the issue. Select a file on your desktop, and drag it to the window that this test project creates. You must drag it to the window within ~1 second to reproduce the bug. You should see "in on_drag_leave" appear in stderr, despite the mouse remaining within the Window.

void main(string[] args) {
    Gtk.init(ref args);
    new MainWindow();
    Gtk.main();
}

public class MainWindow : Gtk.Window {
    private const string URI_LIST_MIME_TYPE = "text/uri-list";

    public MainWindow() {
        destroy.connect(Gtk.main_quit);
        set_size_request(450, 50);
        title = "Main Window";

        Gtk.Widget destination = new Gtk.Label("Drag a file here");
        const Gtk.TargetEntry[] target_entries = { { URI_LIST_MIME_TYPE, 0, 0 } };
        Gtk.drag_dest_set(destination, Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
            target_entries, Gdk.DragAction.COPY);
        destination.drag_data_received.connect(on_drag_data_received);
        destination.drag_drop.connect(on_drag_drop);
        destination.drag_leave.connect(on_drag_leave);
        add(destination);

        show_all();
    }

    private void on_drag_data_received(Gtk.Widget sender, Gdk.DragContext context, int x, int y,
        Gtk.SelectionData selection_data, uint info, uint time_) {

        bool dnd_success = false;
        if (selection_data.get_length() >= 0) {
            string string_data = (string)selection_data.get_data();
            stderr.printf("Received %s: '%s'\n", URI_LIST_MIME_TYPE, string_data);
            dnd_success = true;
        }

        Gtk.drag_finish(context, dnd_success, false, time_);
    }

    private bool on_drag_drop(Gtk.Widget sender, Gdk.DragContext context, int x, int y, uint time_) {
        if (context.list_targets() == null)
            return false;

        uint length = context.list_targets().length();
        Gdk.Atom? target_type = null;
        for (uint i = 0; i < length; i++) {
            Gdk.Atom target = context.list_targets().nth_data(i);
            if (target.name() == URI_LIST_MIME_TYPE)
                target_type = target;
        }

        if (target_type == null)
            return false;

        Gtk.drag_get_data(sender, context, target_type, time_);
        return true;
    }

    private void on_drag_leave() {
        stderr.printf("in on_drag_leave\n");
    }
}

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: unity 5.12-0ubuntu1.1
ProcVersionSignature: Ubuntu 3.2.0-25.40-generic 3.2.18
Uname: Linux 3.2.0-25-generic x86_64
ApportVersion: 2.0.1-0ubuntu8
Architecture: amd64
CompizPlugins: [core,composite,opengl,compiztoolbox,decor,vpswitch,snap,mousepoll,resize,place,move,wall,grid,regex,imgpng,session,gnomecompat,animation,fade,unitymtgrabhandles,workarounds,scale,expo,ezoom,unityshell]
Date: Tue Jun 26 18:06:07 2012
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
SourcePackage: unity
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Can you describe how this bug relates to the Unity launcher (as mentioned in the title)?

Changed in unity (Ubuntu):
status: New → Incomplete
Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

Daniel: The bug only occurs when running Unity (not gnome-shell, etc.), and happens precisely at the moment that the Unity launcher becomes a drop target (either un-hiding itself if it was hidden, or hiding apps that are not drop targets if it was not hidden).

Additionally, in Unity 2D, the launcher does not become a drop target when you start a drag operation, so the bug does not occur.

Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

Here is a screencast demonstrating the issue, along with the source code used for the screencast (slightly modified from the source I posted above).

Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

And here is the source.

Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

Actually, the framerate is too low to see the issue in that video. I will see if I can fix this, and post another video.

Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

Here you go. During the first 3 drags in the video, I demonstrate the issue. During the last 2 drags, I demonstrate that if you wait until after the sidebar appears before dragging the file over the window, the issue does not occur.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Cool, thanks. The video in comment #7 shows the problem.

Changed in unity (Ubuntu):
status: Incomplete → New
summary: - Unity launcher interrupts Gtk drag and drop operation
+ Unity launcher appearing interrupts GTK drag and drop operation (that's
+ nowhere near the launcher)
Revision history for this message
Omer Akram (om26er) wrote :

that's by design. Unity wants the user to know that their dragged file can be dropped over the lightened icons in the launcher to be opened. As you can see gedit is already pinned in the launcher.

Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

Omer: The appearance of the launcher is by design, but it should not interrupt the current drag operation. Watch the small window in the video that I posted to get an idea of what's happening. A spurious "drag-leave" signal is being broadcasted by the window when the launcher appears.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Matthew is right. I don't think Omer has noticed the bug yet.

Revision history for this message
Bilal Akhtar (bilalakhtar) wrote :

It appears the revelation of the launcher is "hijacking" the GTK drag event. Seems like a Compiz bug.

Changed in unity:
status: New → Triaged
Changed in unity (Ubuntu):
status: New → Triaged
Changed in unity:
importance: Undecided → Medium
Changed in unity (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

No, it's nothing to do with compiz. Drag and drop is all Unity code.

no longer affects: compiz (Ubuntu)
Revision history for this message
Matthew Pirocchi (matthew-pirocchi) wrote :

This bug is now removed from compiz, but marked as "Triaged" in Unity. I am re-marking as "New" in Unity.

Changed in unity:
status: Triaged → New
Changed in unity (Ubuntu):
status: Triaged → New
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in unity (Ubuntu):
status: New → Confirmed
Revision history for this message
Drew Snellgrove (forkinme-deactivatedaccount) wrote :

Drag & drop operations in nautilus are also terminated if the mouse button is released at the same time the unity launcher performs its "fade" operation. A demonstration of this issue happens in this screencase (https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1060580/+attachment/3367038/+files/drag%20and%20drop.ogv from an unrelated bug, issue happens at the 32 second mark)

This can be demonstrated across the deaktop and between windows if the mouse button is released during the same fraction of a second the launcher fades. Since this corresponds to a relatively common speed I seem to move at I can have file move operations simple fail to happen up to four times in a row until I'm either faster than when the launcher fade begins or slower than when it ends. In other words if the "hijacking" occurs during the same time I release my mouse button nautilus has no idea where I dropped the file since my mouse has "left" the program's window. If this description is unclear I can try creating a screencast that demonstrates the issue more clearly in Nautilus.

This happened for me under Precise and is still happening under Quantal.

Revision history for this message
Drew Snellgrove (forkinme-deactivatedaccount) wrote :

Actually here's a screencast I made more clearly demonstrating the effects of this bug in nautilus. I try to show that dragging very quickly or very slowly works fine, but dragging and releasing right when the launcher is fading causes the drag to terminate and the icon reset. The 14-21 second stretch includes me repeating it six times in a row on the desktop (this happens in normal usage...oh so frustrating). 35-37 shows it happening twice in a row when dragging from the desktop and a window and at ~57 I managed to do it from the window to the desktop.

Each occurrence of a drag & drop failure corresponds with a seeming "flicker" of the launcher in the video. That's when the launcher fade is only partially complete when releasing the mouse button, causing it to fade back in rapidly.

Stephen M. Webb (bregma)
Changed in unity:
status: New → Triaged
Revision history for this message
Lem (lem-jjr) wrote :

I reported this as a separate bug actually, but this bug report is better than mine. This still happens in 14.04 with 7.1.2+14.04.20131106.1-0ubuntu2

My bug report is at https://bugs.launchpad.net/ubuntu/+source/unity/+bug/970589

Revision history for this message
Lem (lem-jjr) wrote :

I believe https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1060580 is related to this bug, since that bug report describes lag during the panel fade event. I've noticed it in 13.10 and 14.04, that there's a skip in an icon's position during dragging while the Unity panel initiates its fade animation. I'm almost tempted to link these bugs as duplicates, as I believe they're very closely related. At the time an icon skips in its path, in the same moment a drop event would be lost.. actually I will link them, pretty confident and I think it'd be fairly trivial for one of the Compiz/Unity guys to fix, seeing as it happens at such a specific time, and is very easily reproduced.

Drew Snellgrove's video in comment #17 is an extremely good demonstration (thanks Drew!)

Revision history for this message
Lem (lem-jjr) wrote :

I just posted a comment on 1060580 about marking it as a duplicate of this bug. I also had this to add:

On Ubuntu 13.10, it's worth noting that disabling the Unity plugin in CCSM eliminates bug 1060580 and this one. Interestingly, re-enabling the Unity plugin then trying drag and drop again, the panel fade animation doesn't occur, and neither do these two bugs. I'm pretty confident that narrows these bugs down to the panel fade animation.

Revision history for this message
Lem (lem-jjr) wrote :

For what it's worth, this issue is still present in 16.04 as at 2016-04-07.

unity 7.4.0+16.04.20160401.1-0ubuntu1

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.