Dragging or Copy/Pasting URLs from Google Chrome to an Fl_Widget.

12 views
Skip to first unread message

Gonzalo Garramulo

unread,
Jun 5, 2024, 5:47:44 PMJun 5
to fltkg...@googlegroups.com
I am trying to drag and drop the url of a movie file from Google
Chrome/Firefox into my viewer (or, alternatively, paste it).  I just
want to drag/drop the url text not the content.

The url I want to drag, as my viewer can read it just fine, is:

https://dpel-assets.aswf.io/asc-stem2/ASC_StEM2_178_2K_24_100nits_Rec709_Stereo.mp4

My drag and drop code works fine for normal files, but it does not seem
to accept this file.  The view window rejects it with a stop sign and if
I use CTRL-V in my code to paste the text I get a nice:

|00|
|16|

character as if the stuff I am dragging is binary.

I can copy and drag the url with no problems into Thunderbird, or to the
console, btw.

I am trying it on Linux right now.

--
Gonzalo Garramuño
ggar...@gmail.com

Gonzalo Garramulo

unread,
Jun 5, 2024, 5:53:23 PMJun 5
to fltkg...@googlegroups.com

El 5/6/24 a las 18:47, Gonzalo Garramulo escribió:
Actually, I found out I could drag and drop with no problems from
Firefox, but drag and drop from Chrome is a no-go.


--
Gonzalo Garramuño
ggar...@gmail.com

Gonzalo Garramuño

unread,
Jun 5, 2024, 6:14:06 PMJun 5
to fltkg...@googlegroups.com
El 5/6/24 a las 18:53, Gonzalo Garramulo escribió:
> Actually, I found out I could drag and drop with no problems from
> Firefox, but drag and drop from Chrome is a no-go.

More information:

- Drag and Drop from Chrome works fine on Windows and macOS.
- Drag and Drop from Safari also works fine on macOS.

What does not work:

- Drag and Drop from Chrome does NOT work on X11 or Wayland, neither on
Rocky Linux 8.9 nor Ubuntu 22.04.4 LTS.


Gonzalo Garramuño

unread,
Jun 5, 2024, 6:25:34 PMJun 5
to fltkg...@googlegroups.com

El 5/6/24 a las 19:13, Gonzalo Garramuño escribió:
More info.  The demo clipboard.cxx that uses Fl::clipboard_plain_text
does receive the url properly from Chrome.

The problem is with a widget that uses code like:


        case FL_DND_ENTER:
        case FL_DND_LEAVE:
        case FL_DND_DRAG:
        case FL_DND_RELEASE:
        {
            return 1;
        }
        case FL_PASTE:
        {
            std::string text;
            if (Fl::event_text())
                text = Fl::event_text();
            dragAndDrop(text);
            return 1;
        }



Gonzalo Garramuño

unread,
Jun 5, 2024, 6:55:20 PMJun 5
to fltkg...@googlegroups.com

El 5/6/24 a las 19:25, Gonzalo Garramuño escribió:
>
> El 5/6/24 a las 19:13, Gonzalo Garramuño escribió:
>> El 5/6/24 a las 18:53, Gonzalo Garramulo escribió:
>>> Actually, I found out I could drag and drop with no problems from
>>> Firefox, but drag and drop from Chrome is a no-go.
I opened issue #988 with a minimal program.

Ian MacArthur

unread,
Jun 6, 2024, 4:48:41 AMJun 6
to fltk.general
On Wednesday 5 June 2024 at 23:55:20 UTC+1 Gonzalo wrote:
 
>>> Actually, I found out I could drag and drop with no problems from
>>> Firefox, but drag and drop from Chrome is a no-go.
I opened issue #988 with a minimal program.

FWIW, "drag and drop"  always confuses me... At least under X11, I remember staring at the code *a lot* to try and understand it at some point... (and failing...)

Anyway, when the drop happens, the source and destination have a bit of a chat to decide what format they both like best, and then transfer the data in that format. 
I'd have to guess that Firefox offers a simpler set of format options than Chrome does?

It should be possible to have the drop target say it only wants/accepts plain-text though, and Chrome should then honour that preference. 
Not sure how to do that via the FLTK interface though...


Gonzalo Garramuño

unread,
Jun 6, 2024, 4:57:19 AMJun 6
to fltkg...@googlegroups.com

El 6/6/24 a las 05:48, Ian MacArthur escribió:
>
> FWIW, "drag and drop"  always confuses me... At least under X11, I
> remember staring at the code *a lot* to try and understand it at some
> point... (and failing...)

I was able to understand it fine.  There are three problems:

1) with versioning under X11.  Chrome uses v5 of the protocol while FLTK
hard codes it to v4.
2) Chrome does not pass http:// when dragging from a shortened url in
the title bar.  Still looking how to fix that.
3) I am so far unable to make it work in Wayland.  Still looking into
it, but there are less resources and knowledge for it.

Reply all
Reply to author
Forward
0 new messages