Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

X Error in Tk remote drag and drop

by prenaud (Initiate)
on May 27, 2016 at 12:10 UTC ( [id://1164301]=perlquestion: print w/replies, xml ) Need Help??

prenaud has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I use PERL on Linux Mint and I have an error when I drop a file from the Cinnamon desktop on a Tk widget :

X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 25 (X_SendEvent) Resource id in failed request: 0x2fd00fd Serial number of failed request: 164 Current serial number in output stream: 165

My source code is:

#!/usr/bin/perl use strict; use Tk; use Tk::DropSite; my $mw = new MainWindow(-width => 500, -height => 300); my $label = $mw->Label()->pack->place(-relwidth => 1.0, -relheight => +1.0); $label->DropSite(-droptypes => ['XDND'], -dropcommand => [\&dropFile, +$label]); MainLoop; sub dropFile { print "DROP\n"; }

What is wrong in this code ?

Perl version is 5.18.2 and Tk version is 804.033

Thanks for the help.

Replies are listed 'Best First'.
Re: X Error in Tk remote drag and drop
by Marshall (Canon) on May 27, 2016 at 14:45 UTC
    I made a few mods to get this working on Win32.
    On my machine, the use statement required me to specify Win32, there might be some other incantation required on Linux? I also added -text so I could see something to drop onto. Then I took out the -droptypes. There appears to be something wrong with that.

    So, the below does work on my Win32 box. Hopefully this will provide a few clues for your Linux problem.

    #!/usr/bin/perl use strict; use Tk; use Tk::DropSite qw(Win32); my $mw = new MainWindow(-width => 500, -height => 300); my $label = $mw->Label(-text => "this is test")->pack->place(-relwidth + => 1.0, -relheight => 1.0); #$label->DropSite(-droptypes => ['XDND'], -dropcommand => [\&dropFile, + $label]); $label->DropSite( -dropcommand => [\&dropFile, $label]); MainLoop; sub dropFile { print "DROP\n"; }
    Update: I am using Perl 5.22, Active State on Win XP. Tk and DropSite come in the standard dist, so I didn't have to install anything. Sorry I can't be of more help as I have no Linux to test on.
    I did find this article drag n drop primer. It says: "Note: Perl/Tk supports Sun, XDND, KDE, and Win32 remote DND protocols". I suppose this is why I had to add qw(Win32) to the use statement. Could be that what you need is "XDND"? Not sure, but an idea.

      On Windows, there is no problem : if I replace 'XDND' by 'Win32' in the -droptypes option, this code is fully operational.

      The error appears only on Linux.

      Does anybody can try to test this code on a Linux box ?

      I have tested it on Linux Mint which is based on Ubuntu packages.

        I think perhaps we should be clear on what "fully operational" means?

        For me, when I select a file (left click) and drag, the icon should be the "ok, got it", then as mouse moves into the Tk box, it should change to the "no, you cannot drop here icon, the circle surrounding a backslash. If and only if you "find" the label should the icon change back to "ok,got it, you can drop here". If you do not find the label, then the result on my machine is "no error, and no action". That is the reason that I added -text to the label, so I could find it.

        Some of the incantations that I have tried seem inconsistent for reasons that I do not understand, even on Windows. Some of my tests say, OK, you can drop this file anywhere within this Main Window! I reboot the machine and run some intermediate cases and then all of a sudden something different happens.

        I did note the Xwindows error that you are getting. I am wondering if you are seeing the icon behavior that I expect in paragraph one above? It is hard for me to see how you would see that given that this label didn't have any "text" associated with it. I couldn't find the darn thing, because without text it is "invisible".

        My suspicion and testing results seem to indicate that there is something "flaky" here that also appears on Windows. Although I cannot test on Linux, there appears to be something very odd going on which can be hard to reproduce.

Re: X Error in Tk remote drag and drop
by Anonymous Monk on May 29, 2016 at 19:12 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1164301]
Approved by stevieb
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-23 14:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found