Does SDL_DROPFILE work on BSD or Linux?

Hi to all

I gave it a try the example program outlined in the http://wiki.libsdl.org/SDL_DropEvent? on FreeBSD 9.1 using SDL 2.0.

The drag and drop files did not work.

I further added ?SDL_EventState(SDL_DROPFILE, SDL_ENABLE);? but it still did not work.

So, does SDL_DROPFILE work on BSD or Linux?

Regards
Sagara

Hi

It works perfectly for me (on Linux). I get the SDL_DROPFILE event when I drag and drop a file into my window and I can read the correct path of that file from the ‘file’ member of the SDL_DropEvent.

Oh, forgot to mention: Even though it says in the wiki that “This event is disabled by default. You can enable it with SDL_EventState().”, this is unnecessary (on my system). The event seems to be enabled by default for me.

Hi

It’s good to note it works on Linux. But it doesn’t work on FreeBSD!

Thanks.

Regards
Sagara________________________________
From: lgm <xxx.xxx at x-mail.net>
To: sdl at lists.libsdl.org
Sent: Wednesday, October 2, 2013 11:18 AM
Subject: Re: [SDL] Does SDL_DROPFILE work on BSD or Linux?

Hi

It works perfectly for me (on Linux). I get the SDL_DROPFILE event when I drag and drop a file into my window and I can read the correct path of that file from the ‘file’ member of the SDL_DropEvent.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You might try building SDL with DEBUG_EVENTS defined.

The code block for registering a drag and drop event appears in
src/video/x11/SDL_x11events.c at about line 795. It begins with
receipt of a SelectionNotify xevent.

This is a MONSTER function and it’s a little long to process. The
switch in question comes begins on line 322. Were it me, I’d have
broken out those cases into functions with a hint to the compiler
that they’re called only once and should be inlined.

What follows is a check to see if the SelectionNotify is a file being
dropped. If your version of X doesn’t support this somehow, you’ll
never get here. But it’s easy enough to tell either with the
existing debugging or by adding something here.

What follows the test for drag and drop landing on us, SDL asks for
what file and brutally rips off trailing CR/LF. Things to check: Is
this code even getting triggered? Does the file dropped actually end
in CR/LF? And ultimately, is the sanitized and localised filename
terminated with CR and LF?

JosephOn Wed, Oct 02, 2013 at 07:22:46AM -0700, Sagara Wijetunga wrote:

Hi

It’s good to note it works on Linux. But it doesn’t work on FreeBSD!

Thanks.